Re: Understanding intval() and types conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



no..

he didn't.

8.0 = 8.0

7.9999 (repeating) = 7.9999 (repeating)

8.0 != 7.9999 (repeating)

now, if you want to get into conversations with regards to internal binary representations because of the limits of the register architecture in computers, then i might say the issue is the fact that the algorithms employed within the hardware are flawed...

but let's not start screwing with basic math theory....

the statement that he uses where he states that there is a limit to the level of precision is lazy at best... (from a mathmatical perspective)  or can i simply say, 15000 = 14,800 based upon my level of precision....

-bruce



-----Original Message-----
From: Jochem Maas <jochem@xxxxxxxxxxxxx>
Sent: Jan 25, 2005 3:42 PM
To: Bruce Douglas <bedouglas@xxxxxxxxxxxxx>
Cc: ceo@xxxxxxxxx, Jordi Canals <jcanals@xxxxxxxxx>, 
	PHP List <php-general@xxxxxxxxxxxxx>
Subject: Re:  Understanding intval() and types conversion

Bruce Douglas wrote:
> so...
> 
> you're saying that 7.99999 (repeating) is equal to 8.0....
> 
> i say prove it..  as i recall the numbers might be for all practical purposes the same, they are in fact vastly different...
> 
> so, prove your assertion...

he did.

you have to consider the two the same, given that there is always a limit to the
level of precision - the alternative would be to say no 2 numbers are ever equal and
that make for boring mathematics.

actually the underlying maths kinda makes my head spin :-)

> 
> -bruce
> 
> 
> -----Original Message-----
> From: Richard Lynch <ceo@xxxxxxxxx>
> Sent: Jan 25, 2005 2:57 PM
> To: Jochem Maas <jochem@xxxxxxxxxxxxx>
> Cc: Jordi Canals <jcanals@xxxxxxxxx>, PHP List <php-general@xxxxxxxxxxxxx>
> Subject: Re:  Understanding intval() and types conversion
> 
> 
>>my guess this is a round error issue - never noticed this problem
>>before...
>>this is a problem right? anybody?
> 
> 
> You can say it is a round error issue.
> 
> You can not say it is a problem.
> 
> You simply have to be aware that the float number which you think of as
> 8.0000000000000000000000000000... inside of PHP may well be represented as
> 7.9999999999999999999999999999... down in the guts of the machine.
> 
> It may help you feel better about this if you recall from grade school
> mathematics, that, in point of fact:
> 7.999... is EXACTLY equal to 8.000...
> 
> Those who doubt this fact are requested to remember how to convert
> decimals such as:
> 0.333...
> to fractions (1/3), and then apply that exact same method to 7.999...
> 
> You will quickly find yourself with a fraction (72/9) which is precisely
> equal to 8/1 which is 8.
> 
> EVERY floating point number, then, that ends in x000... has a second
> representation, exactly equal, which ends in (x-1)999...
> 
> Bottom line, however you look at it, is that you can NEVER be 100% certain
> that a computer's float number will convert to what you expect in an
> integer because their internal representation simply does not allow for
> perfection.
> 
> This is a feature, not a bug. :-)
> 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux