Electrical and Computer Engineering
16 of 21
UAH
CPE 112
Warning
•Do not compare floating-point numbers for equality. Remember that the binary representations of floating-point numbers are approximations. Instead, test for near equality.
–Example: fabs(r – s) < 0.00001