2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
13 static const unsigned long
14 B1
= 715094163, /* B1 = (682-0.03306235651)*2**20 */
15 B2
= 696219795; /* B2 = (664-0.03306235651)*2**20 */
18 C
= 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
19 D
= -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
20 E
= 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
21 F
= 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
22 G
= 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
31 typedef unsigned unsigned32
__attribute__((mode(SI
)));
44 hx
= ux
.pt
[n0
]; /* high word of x */
45 sign
=hx
&0x80000000; /* sign= sign(x) */
47 if(hx
>=0x7ff00000) return(x
+x
); /* cbrt(NaN,INF) is itself */
48 if((hx
| ux
.pt
[1-n0
])==0)
49 return(ux
.t
); /* cbrt(0) is itself */
52 /* rough cbrt to 5 bits */
53 if(hx
<0x00100000) /* subnormal number */
54 {ut
.pt
[n0
]=0x43500000; /* set t= 2**54 */
55 ut
.t
*=x
; ut
.pt
[n0
]=ut
.pt
[n0
]/3+B2
;
60 /* new cbrt to 23 bits, may be implemented in single precision */
65 /* chopped to 20 bits and make it larger than cbrt(x) */
66 ut
.pt
[1-n0
]=0; ut
.pt
[n0
]+=0x00000001;
68 /* one step newton iteration to 53 bits with error less than 0.667 ulps */
69 s
=ut
.t
*ut
.t
; /* t*t is exact */
72 r
=(r
-ut
.t
)/(w
+r
); /* r-s is exact */
75 /* restore the sign bit */
79 lt
-= (lt
- (x
/(lt
*lt
))) * 0.333333333333333333333;
85 if ((int) (cbrtl (27.0) + 0.5) != 3)