(at least for GNUC platforms) don't rely on nasty division-by-zero tricks to generate +-inf and nan. instead borrow the bitlevel twiddling javascript uses. I would imagine that this would work for all platforms that use IEEE floats (which is necessarily all platforms for which EF will work), but someone else needs to figure out if windows will work with this code.

This commit is contained in:
toshok%hungry.com 1998-12-16 01:38:18 +00:00
Родитель 92275bef5b
Коммит ad52856eb9
1 изменённых файлов: 23 добавлений и 15 удалений

Просмотреть файл

@ -79,29 +79,37 @@ union dpun {
Flt64 d; Flt64 d;
}; };
union spun {
uint32 s;
Flt32 f;
};
struct DummyInit struct DummyInit
{ {
DummyInit() { DummyInit() {
union dpun u; union dpun du;
union spun su;
#if notyet su.s = 0x7f800000;
floatPositiveInfinity = 1.0f/fZero; floatPositiveInfinity = su.f;
floatNegativeInfinity = -1.0f/fZero;
floatNaN = fZero/fZero;
#endif
u.s.hi = DOUBLE_HI32_EXPMASK; du.s.hi = DOUBLE_HI32_EXPMASK;
u.s.lo = 0x00000000; du.s.lo = 0x00000000;
doublePositiveInfinity = u.d; doublePositiveInfinity = du.d;
su.s = 0xff800000;
floatNegativeInfinity = su.f;
u.s.hi = DOUBLE_HI32_SIGNBIT | DOUBLE_HI32_EXPMASK; du.s.hi = DOUBLE_HI32_SIGNBIT | DOUBLE_HI32_EXPMASK;
u.s.lo = 0x00000000; du.s.lo = 0x00000000;
doubleNegativeInfinity = u.d; doubleNegativeInfinity = du.d;
su.s = 0x7f900000;
floatNaN = su.f;
u.s.hi = DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK; du.s.hi = DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK;
u.s.lo = 0xffffffff; du.s.lo = 0xffffffff;
doubleNaN = u.d; doubleNaN = du.d;
} }
}; };