RE: Math Weirdness

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

 



On 15 July 2008 14:33, tedd advised:

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

Sorry, I do apologise if I came over too strongly -- there was no
intention to offend.

However, you really can't dismiss the effects of round-off errors on
addition and subtraction as lightly as that.  It's simply not true that
approximations only occur at the point of doing multiplication and
division -- there *are* approximations involved in addition and
subtraction, and it is necessary to be aware that this is the case -- as
Jay proved, 0.1+0.2 is hardly ever exactly 0.3. In this sort of case, it
may well be that an appropriate degree of suspicion is simply to round
to 2 decimal places at every stage, or compare the absolute difference
to .001, but nonetheless one has to *know* that this is necessary.

Ummm -- sorry, better </rant>, now!!!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

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