|
![]() Click on image to see enlargment |
|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home bug777.cpp
The programmer expected the test for equality to succeed but instead most compilers test this as not equal. How come? bug777.cpp lint Output
--- Module: bug777.cpp (C++)
_
if( x + y == z )
bug777.cpp(15) : Info 777: Testing floats for equality
Reference Manual Explanation
777 Testing float's for equality -- This message is issued when the
operands of operators == and != are some form of floating type
(float, double, or long double). Testing for equality between
two floating point quantities is suspect because of round-off
error and the lack of perfect representation of fractions. If
your numerical algorithm calls for such testing turn the message
off. The message is suppressed when one of the operands can be
represented exactly, such as 0 or 13.5.
If you have comments or questions about this bug, please post them to our Discussion Forum |
Previous Bug - Bug #864 - July 2009