(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;
};
union spun {
uint32 s;
Flt32 f;
};
struct DummyInit
{
DummyInit() {
union dpun u;
union dpun du;
union spun su;
#if notyet
floatPositiveInfinity = 1.0f/fZero;
floatNegativeInfinity = -1.0f/fZero;
floatNaN = fZero/fZero;
#endif
su.s = 0x7f800000;
floatPositiveInfinity = su.f;
u.s.hi = DOUBLE_HI32_EXPMASK;
u.s.lo = 0x00000000;
doublePositiveInfinity = u.d;
du.s.hi = DOUBLE_HI32_EXPMASK;
du.s.lo = 0x00000000;
doublePositiveInfinity = du.d;
u.s.hi = DOUBLE_HI32_SIGNBIT | DOUBLE_HI32_EXPMASK;
u.s.lo = 0x00000000;
doubleNegativeInfinity = u.d;
su.s = 0xff800000;
floatNegativeInfinity = su.f;
du.s.hi = DOUBLE_HI32_SIGNBIT | DOUBLE_HI32_EXPMASK;
du.s.lo = 0x00000000;
doubleNegativeInfinity = du.d;
u.s.hi = DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK;
u.s.lo = 0xffffffff;
doubleNaN = u.d;
su.s = 0x7f900000;
floatNaN = su.f;
du.s.hi = DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK;
du.s.lo = 0xffffffff;
doubleNaN = du.d;
}
};