Hi Zaxo,
I noticed that this doesn't happen in C ...
bash-2.05b$ cat float.c
#include <stdio.h>
int main () {
float a = 36.8;
float b = 36.6;
if( a >= ( b + 0.2 ) ) { printf ("true\n"); }
}
bash-2.05b$ gcc -o float float.c
bash-2.05b$ ./float
true
... and does happen in Python ...
bash-2.05b$ cat float.py
#!/usr/bin/python
A = 36.8
B = 36.6
if( A >= B + 0.2 ):
print "true"
else:
print "false"
bash-2.05b$ ./float.py
false
I would of included a java example but I aint got all day to download the SDK.
Maybe I'll update with one later. Can you explain why C deals with float point number while Perl and Python appear to have this problem? Is it a compiled verses and interpreted language issue?
Thanks
Plankton: 1% Evil, 99% Hot Gas. |