Y
yong321
With this script
<script>
alert(8/(3-8/3))
</script>
I hope to get 24, but I get 23.99999999999999 in IE 6.0.2800 and
Firefox 1.5.0.4. alert(6/(1-3/4)) returns 24 as expected.
I see a number of threads in this newsgroup about the floating point
issue. It may be hard to get it right. But other languages I tried
don't have this problem with this calculation.
Perl:
C:\>perl -e "print 8/(3-8/3)"
24
Python:
$ python -c 'print 8/(3-8/3.0)' #have to say 3.0, not 3
24.0
Oracle:
SQL> select 8/(3-8/3) from dual;
8/(3-8/3)
----------
24
and awk:
$ awk "BEGIN {print 8/(3-8/3)}"
24
I want to compare the calculation result with 24. What's the best
solution in Javascript? Any advice is appreciated.
Yong Huang
<script>
alert(8/(3-8/3))
</script>
I hope to get 24, but I get 23.99999999999999 in IE 6.0.2800 and
Firefox 1.5.0.4. alert(6/(1-3/4)) returns 24 as expected.
I see a number of threads in this newsgroup about the floating point
issue. It may be hard to get it right. But other languages I tried
don't have this problem with this calculation.
Perl:
C:\>perl -e "print 8/(3-8/3)"
24
Python:
$ python -c 'print 8/(3-8/3.0)' #have to say 3.0, not 3
24.0
Oracle:
SQL> select 8/(3-8/3) from dual;
8/(3-8/3)
----------
24
and awk:
$ awk "BEGIN {print 8/(3-8/3)}"
24
I want to compare the calculation result with 24. What's the best
solution in Javascript? Any advice is appreciated.
Yong Huang