1 /* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 * Optimized by Bruce D. Evans.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 use super::{k_cosf, k_sinf, rem_pio2f}
;
19 /* Small multiples of pi/2 rounded to double precision. */
20 const PI_2
: f32 = 0.5 * 3.1415926535897931160E+00;
21 const S1PIO2
: f32 = 1.0 * PI_2
; /* 0x3FF921FB, 0x54442D18 */
22 const S2PIO2
: f32 = 2.0 * PI_2
; /* 0x400921FB, 0x54442D18 */
23 const S3PIO2
: f32 = 3.0 * PI_2
; /* 0x4012D97C, 0x7F3321D2 */
24 const S4PIO2
: f32 = 4.0 * PI_2
; /* 0x401921FB, 0x54442D18 */
26 pub fn sincosf(x
: f32) -> (f32, f32) {
33 sign
= (ix
>> 31) != 0;
40 /* raise inexact if x!=0 and underflow if subnormal */
42 let x1p120
= f32::from_bits(0x7b800000); // 0x1p120 == 2^120
44 force_eval
!(x
/ x1p120
);
46 force_eval
!(x
+ x1p120
);
50 return (k_sinf(x
as f64), k_cosf(x
as f64));
58 s
= -k_cosf((x
+ S1PIO2
) as f64);
59 c
= k_sinf((x
+ S1PIO2
) as f64);
61 s
= k_cosf((S1PIO2
- x
) as f64);
62 c
= k_sinf((S1PIO2
- x
) as f64);
65 /* -sin(x+c) is not correct if x+c could be 0: -0 vs +0 */
68 s
= k_sinf((x
+ S2PIO2
) as f64);
69 c
= k_cosf((x
+ S2PIO2
) as f64);
71 s
= k_sinf((x
- S2PIO2
) as f64);
72 c
= k_cosf((x
- S2PIO2
) as f64);
84 s
= k_cosf((x
+ S3PIO2
) as f64);
85 c
= -k_sinf((x
+ S3PIO2
) as f64);
87 s
= -k_cosf((x
- S3PIO2
) as f64);
88 c
= k_sinf((x
- S3PIO2
) as f64);
92 s
= k_cosf((x
+ S4PIO2
) as f64);
93 c
= k_sinf((x
+ S4PIO2
) as f64);
95 s
= k_cosf((x
- S4PIO2
) as f64);
96 c
= k_sinf((x
- S4PIO2
) as f64);
103 /* sin(Inf or NaN) is NaN */
104 if ix
>= 0x7f800000 {
109 /* general argument reduction needed */
110 let (n
, y
) = rem_pio2f(x
);
118 #[cfg(feature = "checked")]
120 #[cfg(not(feature = "checked"))]