comparison src/libm/s_scalbn.c @ 3337:9ac6f0782dd6

Fixed bug #814 Daniele Forghieri 2009-09-30 15:40:53 PDT To compile the source in libm the variable huge must be renamed, I choose huge_val The patch attached change it so it compiles
author Sam Lantinga <slouken@libsdl.org>
date Sun, 04 Oct 2009 09:51:04 +0000
parents dc1eb82ffdaa
children
comparison
equal deleted inserted replaced
3336:00fab0ebfe54 3337:9ac6f0782dd6
31 #else 31 #else
32 static double 32 static double
33 #endif 33 #endif
34 two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ 34 two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
35 twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ 35 twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
36 huge = 1.0e+300, tiny = 1.0e-300; 36 huge_val = 1.0e+300, tiny = 1.0e-300;
37 37
38 libm_hidden_proto(scalbn) 38 libm_hidden_proto(scalbn)
39 #ifdef __STDC__ 39 #ifdef __STDC__
40 double scalbn(double x, int n) 40 double scalbn(double x, int n)
41 #else 41 #else
58 } 58 }
59 if (k == 0x7ff) 59 if (k == 0x7ff)
60 return x + x; /* NaN or Inf */ 60 return x + x; /* NaN or Inf */
61 k = k + n; 61 k = k + n;
62 if (k > 0x7fe) 62 if (k > 0x7fe)
63 return huge * copysign(huge, x); /* overflow */ 63 return huge_val * copysign(huge_val, x); /* overflow */
64 if (k > 0) { /* normal result */ 64 if (k > 0) { /* normal result */
65 SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); 65 SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
66 return x; 66 return x;
67 } 67 }
68 if (k <= -54) { 68 if (k <= -54) {
69 if (n > 50000) /* in case integer overflow in n+k */ 69 if (n > 50000) /* in case integer overflow in n+k */
70 return huge * copysign(huge, x); /*overflow */ 70 return huge_val * copysign(huge_val, x); /*overflow */
71 else 71 else
72 return tiny * copysign(tiny, x); /*underflow */ 72 return tiny * copysign(tiny, x); /*underflow */
73 } 73 }
74 k += 54; /* subnormal result */ 74 k += 54; /* subnormal result */
75 SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); 75 SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));