googletest
googletest copied to clipboard
[Bug]: Rounding errors when printing floats/doubles
Describe the issue
On IA-32 floating point literals are internally different, so a simple string compare with Print is not portable:
~/googletest/googletest/test/googletest-printers-test.cc:464: Failure
Expected equality of these values:
"1.1"
Print(1.10000002f)
Which is: "1.10000002"
~/googletest/googletest/test/googletest-printers-test.cc:466: Failure
Expected equality of these values:
"9e+09"
Print(9e9f)
Which is: "8.99999949e+09"
[ FAILED ] PrintBuiltInTypeTest.FloatingPoints (0 ms)
Expected equality of these values:
"(1.1)"
PrintToString(internal::Optional<double>{1.1})
Which is: "(1.1000000000000001)"
[ FAILED ] PrintOptionalTest.Basic (0 ms)
Steps to reproduce the problem
make test
on IA-32
What version of GoogleTest are you using?
1.13.0
What operating system and version are you using?
Archlinux32
What compiler and version are you using?
gcc (GCC) 12.2.1 20230111
What build system are you using?
cmake version 3.25.1 GNU Make 4.4.1
Additional context
No response
hey, I'd like to work on this issue
I'd be more than happy to take over the issue if someone can do a basic code walkthrough for me, regarding what all places do I need to look into and such.