http://www.perlmonks.org?node_id=382104


in reply to Re^2: float values and operators
in thread float values and operators

Are you sure C "deals"?

$ cat imprec.c #include <stdio.h> int main () { float fa = 36.8; float fb = 36.6; double da = 36.8; double db = 36.6; printf( ( fa >= ( fb + 0.2 ) ) ? "true\n" : "false\n" ); printf( ( da >= ( db + 0.2 ) ) ? "true\n" : "false\n" ); } $ gcc -o imprec imprec.c $ ./imprec true false

You're seeing the result of cut-off caused by float's lower precision.

Perl and Python use doubles in all floating point operations.

Makeshifts last the longest.