RE: Math Weirdness

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

 



hi..


in all seriousness, when you talk about mathmetical operations, you need to
really clearly define what the parameters of the conversation are. are you
just restricting the conversation to ints, or floats as well.. you should
also restrict the range of the number you're discussing.

for most of what the majority of php/script apps deal with, it's probably
safe to assume that addition/subtraction will be safe, but i can think of
numerous examples where this isn't true...

the internal representation of a number/value is really complex when you get
into the guts of the cpu/fpu... and it can be hairy as hell to get it right,
depending on what you're doing... that said, the vast majority of php will
never think about this, and the world will still keep spinning!!

anyone remember the intel debacle in the 1990's.. when they ate a couple
hundred million when they had a math err in one of their coprocessors!

peace..


-----Original Message-----
From: tedd [mailto:tedd.sperling@xxxxxxxxx]
Sent: Tuesday, July 15, 2008 6:33 AM
To: php php
Subject: RE:  Math Weirdness


At 11:24 AM +0100 7/15/08, Ford, Mike wrote:
>On 14 July 2008 20:47, tedd advised:
>
>  > Round-off errors normally don't enter into things unless your doing
>  > multiplication and division operations. At that point, what you get
>>  back from the operation is an approximation and not the actual
>>  number.
>
>Bull! Nearly all computer floating point numbers are approximations
>because of being held in binary rather than decimal. Any number with a
>(decimal) fractional part that doesn't end with the digit 5 is
>necessarily an approximation, and that's only half the story. So as soon
>as you involve numbers like 0.1 or 0.2, you've already got minor
>inaccuracies which will propagate through any kind of arithmetic -- it's
>just worse with multiplication or division because these tend to result
>in inaccuracy in more significant digits!
>
>Bottom line: a floating point value should *always* be treated with an
>appropriate degree of suspicion.
>
>Cheers!
>
>Mike

Mike:

No reason to be rude.

I said:

"Round-off errors normally don't enter into things unless your doing
multiplication and division operations."

And that is not "Bull" -- it's true. You can add and subtract all the
floating point numbers (the one's we are talking about here) you want
without any rounding errors whatsoever.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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


-- 
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