factor
factor copied to clipboard
linux32 test NAN: 123 test fails but only on test-all
! the test:
resource:basis/prettyprint/prettyprint-tests.factor: 26
Unit Test: { { "NAN: 123" } [ NAN: 8000000000123 unparse ] }
=== Expected:
"NAN: 123"
=== Got:
"NAN: 8000000000123"
! on mac64
[ 0x7ff0000000000123 bits>double unparse . ] collect-fp-exceptions . ! NAN: 123
[ 0x7ff8000000000123 bits>double unparse . ] collect-fp-exceptions . ! NAN: 8000000000123
"NAN: 123"
{ +fp-invalid-operation+ +fp-inexact+ }
"NAN: 8000000000123"
{ +fp-inexact+ }
0x7ff0000000000123 bits>double fp-qnan? .
f
0x7ff8000000000123 bits>double fp-qnan? .
t
This is a C++ way to get the numbers but it doesn't trigger fp exceptions like we want (this breaking USE: math.floats.env)
some leads on abi differences on x86 vs x64 https://www.boost.org/doc/libs/1_78_0/libs/context/doc/html/context/rationale/x86_and_floating_point_env.html
https://www.agner.org/optimize/calling_conventions.pdf
// cat vm/float_bits.hpp
namespace factor {
inline static uint64_t double_bits(double x) {
return *(reinterpret_cast<uint64_t*>(&x));
}
inline static double bits_double(uint64_t y) {
return *(reinterpret_cast<double*>(&y));
}
inline static uint32_t float_bits(float x) {
return *(reinterpret_cast<uint32_t*>(&x));
}
inline static float bits_float(uint32_t y) {
return *(reinterpret_cast<float*>(&y));
}
}
Possibly works on Ubuntu16 but fails on Ubuntu18. Fails immediately on Ubuntu18 with NAN: 123