tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.5k stars 423 forks source link

Floating point equality #318

Open Crzyrndm opened 6 years ago

Crzyrndm commented 6 years ago

GCC and Clang have -Wfloat-equal that warns on the use of float/double::operator==, and for good reason (MSVC doesn't appear to have a similar warning).

Some references on float equality, why it should be enabled, and how to make the comparison in a less error prone manner

Crzyrndm commented 6 years ago

Also, the Approx class in the Catch2 test framework

sukoi26 commented 6 years ago

i recommend reading on the UNUM ( universal number ) to understand the error with the use of IEEE Standard for Floating-Point Arithmetic (IEEE 754)

https://en.wikipedia.org/wiki/Unum_(number_format)

paulharris commented 6 years ago

This is excellent reading, and has code to match that you can copy paste if you don't want to suck in the whole boost library (copy from header)

https://www.boost.org/doc/libs/1_67_0/libs/math/doc/html/math_toolkit/float_comparison.html

On Sun., 22 Jul. 2018, 1:59 pm sukoi26, notifications@github.com wrote:

i recommend reading on the UNUM ( universal number ) to understand the error with the use of IEEE Standard for Floating-Point Arithmetic (IEEE 754)

https://en.wikipedia.org/wiki/Unum_(number_format)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tfussell/xlnt/issues/318#issuecomment-406843298, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkgSyTQd2aqYkB7CxAQdda21JWRJ-VNks5uJBTHgaJpZM4VZZvp .