]>
git.proxmox.com Git - rustc.git/blob - vendor/libm-0.1.4/src/math/asinf.rs
1 /* origin: FreeBSD /usr/src/lib/msun/src/e_asinf.c */
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
13 * ====================================================
16 use super::fabsf
::fabsf
;
17 use super::sqrt
::sqrt
;
19 const PIO2
: f64 = 1.570796326794896558e+00;
21 /* coefficients for R(x^2) */
22 const P_S0
: f32 = 1.6666586697e-01;
23 const P_S1
: f32 = -4.2743422091e-02;
24 const P_S2
: f32 = -8.6563630030e-03;
25 const Q_S1
: f32 = -7.0662963390e-01;
29 let p
= z
* (P_S0
+ z
* (P_S1
+ z
* P_S2
));
30 let q
= 1. + z
* Q_S1
;
36 /// Computes the inverse sine (arc sine) of the argument `x`.
37 /// Arguments to asin must be in the range -1 to 1.
38 /// Returns values in radians, in the range of -pi/2 to pi/2.
40 #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
41 pub fn asinf(mut x
: f32) -> f32 {
42 let x1p_120
= f64::from_bits(0x3870000000000000); // 0x1p-120 === 2 ^ (-120)
45 let ix
= hx
& 0x7fffffff;
51 return ((x
as f64) * PIO2
+ x1p_120
) as f32; /* asin(+-1) = +-pi/2 with inexact */
53 return 0. / (x
- x
); /* asin(|x|>1) is NaN */
58 /* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */
59 if (ix
< 0x39800000) && (ix
>= 0x00800000) {
62 return x
+ x
* r(x
* x
);
66 let z
= (1. - fabsf(x
)) * 0.5;
67 let s
= sqrt(z
as f64);
68 x
= (PIO2
- 2. * (s
+ s
* (r(z
) as f64))) as f32;