|
Posted by Philip Ronan on 12/05/05 14:15
"mat" wrote:
> Thanks Philip and Ian, a real help.
>
> Working on what Philip said about Windows just rounding, I did the same
> and it works for me:
>
> round($_SESSION["c"]-$_SESSION["a"],2)
>
> Is this wrong / ill advised for any reason? Or just another way...
No, that's fine. Just bear in mind that the round() function returns a
floating point value, so you still shouldn't expect it to be exactly equal
to the rounded number.
This is a problem common to all programming languages, not just PHP. You
should never expect floating point values to be exactly equal to anything.
Code like this just won't work properly:
$x = 1/10;
if ($x == 0.1) { ... do something ...}
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
[Back to original message]
|