Re: Missing 0.0000001 - driving me crazy - help!



On Mon, 05 Dec 2005 11:14:32 +0000, mat <yub_notthis_huntleyboo@xxxxxxxxxxx>
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@xxxxxxxxxxx :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
.



Relevant Pages

  • Re: Missing 0.0000001 - driving me crazy - help!
    ... > Thanks Philip and Ian, ... > Working on what Philip said about Windows just rounding, ... should never expect floating point values to be exactly equal to anything. ...
    (comp.lang.php)
  • Re: x86 exception handling and stack demand
    ... "there isn't any floating point state, ... The current design makes me pay that price regardless. ... Windows, because its just, well, slow. ... optimized accordingly (better to increase the per-thread cost than the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Multithreading on Multicore Processors
    ... floating point calculations. ... insomuch as floating point calculation ... The 16 codes of the Polyhedron Fortran benchmark run on both Windows ... management and process priority management has more to do with it. ...
    (comp.lang.fortran)
  • Re: Custom Keyboard Shortcuts in Gnome (Solved)
    ... On Wed, 2004-06-02 at 23:10, Philip A. Chapman wrote: ... click on the pair and enter the command to run in the "key value" field. ... Linux, Windows 9x, Windows NT, Windows 2000, Windows XP ...
    (Fedora)
  • Re: Strange (long double) results from simple program
    ... no error messages anywhere (not during compile, ... Some of the ports of gcc to Windows, such as MinGW, do not provide a ... gcc is passing 80-bit x86 extended precision floating ...
    (comp.lang.c.moderated)