Fix sincosf(PI) (#229)
Looks like the implementation was not ported correctly. Some negations
were forgotten in a certain branch. Here is the original code in musl
that has the negations:
94cb2ec2a0/src/math/sincosf.c (L66-L67)
Resolves rust-lang/libm#228
This commit is contained in:
parent
52ecbdd9c0
commit
3b3f3e977c
1 changed files with 17 additions and 4 deletions
|
|
@ -65,11 +65,11 @@ pub fn sincosf(x: f32) -> (f32, f32) {
|
|||
/* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */
|
||||
else {
|
||||
if sign {
|
||||
s = k_sinf((x + S2PIO2) as f64);
|
||||
c = k_cosf((x + S2PIO2) as f64);
|
||||
s = -k_sinf((x + S2PIO2) as f64);
|
||||
c = -k_cosf((x + S2PIO2) as f64);
|
||||
} else {
|
||||
s = k_sinf((x - S2PIO2) as f64);
|
||||
c = k_cosf((x - S2PIO2) as f64);
|
||||
s = -k_sinf((x - S2PIO2) as f64);
|
||||
c = -k_cosf((x - S2PIO2) as f64);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,3 +121,16 @@ pub fn sincosf(x: f32) -> (f32, f32) {
|
|||
_ => (0.0, 1.0),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::sincosf;
|
||||
use crate::_eqf;
|
||||
|
||||
#[test]
|
||||
fn with_pi() {
|
||||
let (s, c) = sincosf(core::f32::consts::PI);
|
||||
_eqf(s.abs(), 0.0).unwrap();
|
||||
_eqf(c, -1.0).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue