Re: [PHP-DB] mathematical discrepancies

2008-08-14 Thread Yves Sucaet
PROTECTED]> To: Sent: Thursday, August 14, 2008 7:55 AM Subject: [PHP-DB] mathematical discrepancies Hello, Can anybody shed any light on this behaviour please? PHP Version 5.2.5 on XP $a = 1754.00 ; $b = 1754.03 ; $diff = abs($b) - abs($a); echo "$diff"; //output: 0.03

Re: [PHP-DB] mathematical discrepancies

2008-08-14 Thread Evert Lammerts
Check http://php.net/manual/en/language.types.float.php Quote: Warning Floating point precision It is typical that simple decimal fractions like 0.1 or 0.7 cannot be converted into their internal binary counterparts without a small loss of precision. This can lead to confusing results: for examp

[PHP-DB] mathematical discrepancies

2008-08-14 Thread Andrew Martin
Hello, Can anybody shed any light on this behaviour please? PHP Version 5.2.5 on XP $a = 1754.00 ; $b = 1754.03 ; $diff = abs($b) - abs($a); echo "$diff"; //output: 0.03 $a = 1754.00 ; $b = 1754.09 ; $diff = abs($b) - abs($a); echo "$diff"; //output :0.08999 $a = 1754.01 ; $