1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use super::{get_high_word, k_cos, k_sin, rem_pio2};
pub fn sincos(x: f64) -> (f64, f64) {
let s: f64;
let c: f64;
let mut ix: u32;
ix = get_high_word(x);
ix &= 0x7fffffff;
if ix <= 0x3fe921fb {
if ix < 0x3e46a09e {
let x1p120 = f64::from_bits(0x4770000000000000);
if ix < 0x00100000 {
force_eval!(x / x1p120);
} else {
force_eval!(x + x1p120);
}
return (x, 1.0);
}
return (k_sin(x, 0.0, 0), k_cos(x, 0.0));
}
if ix >= 0x7ff00000 {
let rv = x - x;
return (rv, rv);
}
let (n, y0, y1) = rem_pio2(x);
s = k_sin(y0, y1, 1);
c = k_cos(y0, y1);
match n & 3 {
0 => (s, c),
1 => (c, -s),
2 => (-s, -c),
3 => (-c, s),
#[cfg(feature = "checked")]
_ => unreachable!(),
#[cfg(not(feature = "checked"))]
_ => (0.0, 1.0),
}
}