Re: PHP can't add up??!
From: Joe (yojimbo99_at_uboot.com)
Date: 02/04/04
- Next message: Jerry Sievers: "Re: No tutorials/examples to be found on using PHP dbm-style functions with apache's mod_auth_db"
- Previous message: Toby Newman: "PHP can't add up??!"
- In reply to: Toby Newman: "PHP can't add up??!"
- Next in thread: Toby Newman: "Re: PHP can't add up??!"
- Reply: Toby Newman: "Re: PHP can't add up??!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 04 Feb 2004 17:31:34 +0100
Toby Newman wrote:
> Please can someone explain why the following code generates
> -0.049999999999999 rather than -0.05?
>
> <?php
> echo(8.23 + (-8.28));
> ?>
>
> Thanks!
> Toby
I think you have to go through the basics of 'how are floating point
numbers represented in computers'. As far as I remember is it a long
time existing problem of how to generate an exact binary representation
of decimal numbers for usage in computers...
Some hints if you need more
http://iis1.cps.unizar.es/Oreilly/perl/cookbook/ch02_05.htm
http://www.cs.rpi.edu/~hollingd/comporg/notes/fp/fp.pdf
or find some information yourself:
Hope it helps a bit.
Joe
- Next message: Jerry Sievers: "Re: No tutorials/examples to be found on using PHP dbm-style functions with apache's mod_auth_db"
- Previous message: Toby Newman: "PHP can't add up??!"
- In reply to: Toby Newman: "PHP can't add up??!"
- Next in thread: Toby Newman: "Re: PHP can't add up??!"
- Reply: Toby Newman: "Re: PHP can't add up??!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|