<?php
echo (int) ( (0.1+0.7) * 10 ); // echoes 7!
?>
echo (int) ( (0.2+0.7) * 10 )
$ perl -e "print int((0.1+0.7) * 10)"
7
$ perl -e "print int((0.1+0.7) * 10)"
9
$ perl -v
This is perl, v5.10.1 (*) built for i386-freebsd
...
b@thinkpad:~$ php -r'echo (int) ( (0.1+0.7) * 10 ),"\n";'
7
b@thinkpad:~$ php -r'echo (int) ( (0.2+0.7) * 10 ),"\n";'
9
b@thinkpad:~$ php -v
PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:41:55)
Copyright © 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2010 Zend Technologies
$ perl -e "printf('%.45f',0.1)"
0.100000000000000005551115123125782702118158340
$ perl -e "printf('%.45f',0.7)"
0.699999999999999955591079014993738383054733276
$ ruby -e "printf('%.45f',0.8)"
0.800000000000000044408920985006261616945266724