|
Posted by Andy Hassall on 12/05/05 21:28
On Mon, 05 Dec 2005 11:14:32 +0000, mat <yub_notthis_huntleyboo@yahoo.co.uk>
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...
You appear to be working with monetary values from the names in your original
post. You shouldn't use floating point numbers for money; use integers,
multiplied up to the minor currency. So £1.50 = 150.
This way the floating point inaccuracies (which are not specific to Windows or
PHP, they are fundamental to the way x86 and many other processors handle
floating point numbers) don't become an issue, because you're always dealing
with exact integer calculations.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|