Here's the code:

<?php
$a = 676.6;
$b = 0.175;

$y = $a * (1 + $b);
echo("y: " . $a . " * (1 + " . $b . ") = $y<BR>");

$z = $a + ($a * $b);
echo("z: " . $a . " + ( " . $a . " * " . $b . ") = $z<BR>");

echo("number format(y)=".number_format($y, 2)."<BR>");
echo("number format(z)=".number_format($z, 2)."<BR>");
?>


Here's the output:

y: 676.6 * (1 + 0.175) = 795.005
z: 676.6 + ( 676.6 * 0.175) = 795.005
number format(y)=795.01
number format(z)=795.00


In other words, using two logically equivalent (?) formulae to derive
exactly the same result from the same two values results in somehow
different results (I guess it's not an issue with number_format() per se,
but with associativity or summat...).

Hope it's not an obvious schoolboy error - any ideas?

PHP 4.2.2
Apache 2.0.40
Redhat 7.3
-------------------------------------------------------
Paul Hopkins - Senior Web Developer, Doctor Net - http://www.doc-net.com/

The information transmitted is intended only for the person or entity to
which it is
addressed and may contain confidential and/or privileged material. If you
received
this in error, please contact the sender and delete the material.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to