-
Notifications
You must be signed in to change notification settings - Fork 134
Description
See a minimal working example here.
If I attempt a comparison such as
double a = 1.e19;
expect(a == _d(1.e19));
then the resulting program hangs. Using 1.e18 instead is no problem. I did not check values in between.
This is compiled with GCC 13.3.0 installed on Ubuntu 24.04.4 LTS via apt.
Compiling with -D CMAKE_BUILD_TYPE=Debug and -D CMAKE_BUILD_TYPE=Release both trigger the bug.
I realize it's a bit strange to perform an equality comparison of two floating points that are fairly large. I encountered this when writing a parser for an input file format used in chemistry communities. The file format is a bit complex and includes physical quantities that can be very large (>1.e20), so it is worth it to check that I read the files correctly. In this case, the read number should be unspoiled by floating point arithmetic errors and so (conceptually) a direct equality check is the appropriate thing to do.
My workaround is to check relative error:
double a = 1.e19;
expect(std::abs(a - 1.e19) / 1.e19 <= _d(1.e-9));
This is acceptable for my use case, but thought I would share the bug.