1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #include "cdefs-compat.h"
- #include <openlibm_math.h>
- #include "math_private.h"
- static const unsigned
- B1 = 709958130,
- B2 = 642849266;
- OLM_DLLEXPORT float
- cbrtf(float x)
- {
- double r,T;
- float t;
- int32_t hx;
- u_int32_t sign;
- u_int32_t high;
- GET_FLOAT_WORD(hx,x);
- sign=hx&0x80000000;
- hx ^=sign;
- if(hx>=0x7f800000) return(x+x);
-
- if(hx<0x00800000) {
- if(hx==0)
- return(x);
- SET_FLOAT_WORD(t,0x4b800000);
- t*=x;
- GET_FLOAT_WORD(high,t);
- SET_FLOAT_WORD(t,sign|((high&0x7fffffff)/3+B2));
- } else
- SET_FLOAT_WORD(t,sign|(hx/3+B1));
-
- T=t;
- r=T*T*T;
- T=T*((double)x+x+r)/(x+r+r);
-
- r=T*T*T;
- T=T*((double)x+x+r)/(x+r+r);
-
- return(T);
- }
|