From:             [EMAIL PROTECTED]
Operating system: Red Hat Linux 6.2
PHP version:      4.0.4pl1
PHP Bug Type:     Math related
Bug description:  Round error

Execute this script:
<?
        $a = 250.02;
        $b = 210.10;
        $c =  39.92;

        echo "a = $a<br>\n";
        echo "b = $b<br>\n";
        echo "c = $c<br>\n";

        echo "(b+c)-a = " . (($b+$c)-$a) . "<br>\n";
?>

It SHOULD echo:
a = 250.02
b = 210.1
c = 39.92
(b+c)-a = 0

But it echoes on my machine:
a = 250.02
b = 210.1
c = 39.92
(b+c)-a = -2.8421709430404E-14

When you change the values, for example like this:
<?
        $a = 250.022;
        $b = 210.101;
        $c =  39.921;
?>
it echoes the correct values... if against all odds I am doing something wrong, please 
tell me....!

Marc, a very happy php programmer!


P.S. I compiled PHP with this command line:

'./configure' '--with-mysql' '--with-pgsql' '--with-esoob' '--with-magic-quotes' 
'--with-apxs' '--with-ftp' '--with-config-file-path=.'


-- 
Edit Bug report at: http://bugs.php.net/?id=10131&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to