mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-11 00:52:39 +00:00
libm: use union for infinity
This commit is contained in:
committed by
Anonymous Maarten
parent
474c8d0073
commit
a84389f6bb
@@ -98,6 +98,13 @@ P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
|
||||
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
|
||||
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
|
||||
|
||||
union {
|
||||
Uint64 u64;
|
||||
double d;
|
||||
} inf_union = {
|
||||
0x7ff0000000000000 /* Binary representation of a 64-bit infinite double (sign=0, exponent=2047, mantissa=0) */
|
||||
};
|
||||
|
||||
double __ieee754_exp(double x) /* default IEEE double exp */
|
||||
{
|
||||
double y;
|
||||
@@ -123,6 +130,8 @@ double __ieee754_exp(double x) /* default IEEE double exp */
|
||||
else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
|
||||
}
|
||||
#if 1
|
||||
if(x > o_threshold) return inf_union.d; /* overflow */
|
||||
#elif 1
|
||||
if(x > o_threshold) return huge*huge; /* overflow */
|
||||
#else /* !!! FIXME: check this: "huge * huge" is a compiler warning, maybe they wanted +Inf? */
|
||||
if(x > o_threshold) return INFINITY; /* overflow */
|
||||
|
||||
Reference in New Issue
Block a user