61 * no finite(x) ? |
62 * no finite(x) ? |
62 * no isnan(x) ? |
63 * no isnan(x) ? |
63 */ |
64 */ |
64 # ifndef isnanl |
65 # ifndef isnanl |
65 # define isnanl(x) \ |
66 # define isnanl(x) \ |
66 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
67 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
67 (((unsigned int *)(&x))[1] == 0xC0000000) && \ |
68 (((unsigned int *)(&x))[1] == 0xC0000000) && \ |
68 (((unsigned short *)(&x))[4] == 0xFFFF)) |
69 (((unsigned short *)(&x))[4] == 0xFFFF)) |
69 # endif |
70 # endif |
70 |
71 |
71 # ifndef isnan |
72 # ifndef isnan |
72 # define isnan(x) \ |
73 # define isnan(x) \ |
73 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
74 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
74 (((unsigned int *)(&x))[1] == 0xFFF80000)) |
75 (((unsigned int *)(&x))[1] == 0xFFF80000)) |
75 # endif |
76 # endif |
76 |
77 |
77 # ifndef isPositiveInfinity |
78 # ifndef isPositiveInfinity |
78 # define isPositiveInfinity(x) \ |
79 # define isPositiveInfinity(x) \ |
79 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
80 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
80 (((unsigned int *)(&x))[1] == 0x7FF00000)) |
81 (((unsigned int *)(&x))[1] == 0x7FF00000)) |
81 # endif |
82 # endif |
82 |
83 |
83 # ifndef isNegativeInfinity |
84 # ifndef isNegativeInfinity |
84 # define isPositiveInfinity(x) \ |
85 # define isPositiveInfinity(x) \ |
85 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
86 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
86 (((unsigned int *)(&x))[1] == 0xFFF00000)) |
87 (((unsigned int *)(&x))[1] == 0xFFF00000)) |
87 # endif |
88 # endif |
88 |
89 |
89 # ifndef isinf |
90 # ifndef isinf |
90 # define isinf(x) \ |
91 # define isinf(x) \ |
91 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
92 ((((unsigned int *)(&x))[0] == 0x00000000) && \ |
92 ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000)) |
93 ((((unsigned int *)(&x))[1] & 0x7FF00000) == 0x7FF00000)) |
93 # endif |
94 # endif |
94 |
95 |
95 # ifndef finite |
96 # ifndef finite |
96 # define finite(x) (!isinf(x) && !isnan(x)) |
97 # define finite(x) (!isinf(x) && !isnan(x)) |
97 # endif |
98 # endif |
166 # define LONGFLOAT_CLASS LongFloat |
158 # define LONGFLOAT_CLASS LongFloat |
167 # define LONGFLOAT_GLOBAL @global(LongFloat) |
159 # define LONGFLOAT_GLOBAL @global(LongFloat) |
168 #endif |
160 #endif |
169 |
161 |
170 struct __longfloatstruct { |
162 struct __longfloatstruct { |
171 HEADER |
163 HEADER |
172 #ifdef __NEED_DOUBLE_ALIGN |
164 #ifdef __NEED_DOUBLE_ALIGN |
173 __FILLTYPE_DOUBLE f_filler; |
165 __FILLTYPE_DOUBLE f_filler; |
174 #endif |
166 #endif |
175 LONGFLOAT f_longfloatvalue; |
167 LONGFLOAT f_longfloatvalue; |
176 }; |
168 }; |
177 #define __LongFloatInstPtr(obj) ((struct __longfloatstruct *)(__objPtr(obj))) |
169 #define __LongFloatInstPtr(obj) ((struct __longfloatstruct *)(__objPtr(obj))) |
178 |
170 |
179 #ifndef __longFloatVal |
171 #ifndef __longFloatVal |
180 # define __longFloatVal(o) \ |
172 # define __longFloatVal(o) \ |
181 __LongFloatInstPtr(o)->f_longfloatvalue |
173 __LongFloatInstPtr(o)->f_longfloatvalue |
182 #endif |
174 #endif |
183 |
175 |
184 #ifndef __qMKLFLOAT |
176 #ifndef __qMKLFLOAT |
185 # define __qMKLFLOAT(__newFloat__, __fVal__) \ |
177 # define __qMKLFLOAT(__newFloat__, __fVal__) \ |
186 { \ |
178 { \ |
187 __qNew(__newFloat__ , sizeof(struct __longfloatstruct)); \ |
179 __qNew(__newFloat__ , sizeof(struct __longfloatstruct)); \ |
188 if (__newFloat__) { \ |
180 if (__newFloat__) { \ |
189 __qClass(__newFloat__) = LONGFLOAT_GLOBAL; \ |
181 __qClass(__newFloat__) = LONGFLOAT_GLOBAL; \ |
190 __LongFloatInstPtr(__newFloat__)->f_longfloatvalue = (LONGFLOAT)(__fVal__); \ |
182 __LongFloatInstPtr(__newFloat__)->f_longfloatvalue = (LONGFLOAT)(__fVal__); \ |
191 } \ |
183 } \ |
192 } |
184 } |
193 #endif |
185 #endif |
194 |
186 |
195 #ifndef __isLongFloat |
187 #ifndef __isLongFloat |
196 # define __isLongFloat(o) \ |
188 # define __isLongFloat(o) \ |
197 (__Class(o) == @global(LongFloat)) |
189 (__Class(o) == @global(LongFloat)) |
198 #endif |
190 #endif |
199 |
191 |
200 #ifndef __qIsLongFloat |
192 #ifndef __qIsLongFloat |
201 # define __qIsLongFloat(o) \ |
193 # define __qIsLongFloat(o) \ |
202 (__qClass(o) == @global(LongFloat)) |
194 (__qClass(o) == @global(LongFloat)) |
203 #endif |
195 #endif |
204 |
196 |
205 %} |
197 %} |
206 ! ! |
198 ! ! |
207 |
199 |
1651 |
1640 |
1652 #ifdef LONG_finite |
1641 #ifdef LONG_finite |
1653 LONGFLOAT lV = __longFloatVal(self); |
1642 LONGFLOAT lV = __longFloatVal(self); |
1654 |
1643 |
1655 if (LONG_finite(lV)) { |
1644 if (LONG_finite(lV)) { |
1656 RETURN (true); |
1645 RETURN (true); |
1657 } else { |
1646 } else { |
1658 RETURN (false); |
1647 RETURN (false); |
1659 } |
1648 } |
1660 #else |
1649 #else |
1661 double dV = (double) __longFloatVal(self); |
1650 double dV = (double) __longFloatVal(self); |
1662 |
1651 |
1663 if (finite(dV)) { |
1652 if (isfinite(dV)) { |
1664 RETURN (true); |
1653 RETURN (true); |
1665 } else { |
1654 } else { |
1666 RETURN (false); |
1655 RETURN (false); |
1667 } |
1656 } |
1668 #endif |
1657 #endif |
1669 %} |
1658 %} |
1670 |
1659 |
1671 " |
1660 " |
1672 1.0 asLongFloat isFinite |
1661 1.0 asLongFloat isFinite |
1673 (0.0 asLongFloat uncheckedDivide: 0.0) isFinite |
1662 (0.0 asLongFloat uncheckedDivide: 0.0) isFinite |
1674 (1.0 asLongFloat uncheckedDivide: 0.0) isFinite |
1663 (1.0 asLongFloat uncheckedDivide: 0.0) isFinite |
1675 (-1.0 asLongFloat uncheckedDivide: 0.0) isFinite |
1664 (-1.0 asLongFloat uncheckedDivide: 0.0) isFinite |
1676 " |
1665 " |
1677 ! |
1666 ! |
1678 |
1667 |
1679 isNaN |
1668 isNaN |
1680 "return true, if the receiver is an invalid float (NaN - not a number). |
1669 "return true, if the receiver is an invalid float (NaN - not a number). |