TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Rule:  6.5.8.d

Synopsis:Comparison of floating point numbers (float or double) shall preferably be avoided.
Language:C
Severity Level:8
Category:Expressions


Description:

Justification

Floating point numbers are by definition inaccurate and rounding errors can be accumulated during computation.

Example

float test1 = 10.1;
float test2 = 10.099;
float test3 = test2 + 100000;
test3 -= 100000;

if (test1 > test2) /* true */
                
if (test1 > test3) /* false, because test1 = 10.10000038 and test3 = 10.10156250 */