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

RE: [f-cpu] Re: Floating-Point?



> 
> > Yes, you will get
> > rounding errors but you need a heck of a lot of calculations for the
> > rounding errors in the 16'th decimal place to add up to 
> > anything of any significance.
> 
> I just found an article that outlines the problem I stated 
> more precisely
> than I can:
> 
> http://www.math.grin.edu/~stone/courses/fundamentals/IEEE-reals.html

Interesting article.

> 
> The article says:
> 
> "For instance, 7/5 is 1.4 exactly in decimal numeration, but 
> the .4 part
> cannot be expressed as a sum of powers of two; 7/5 has an 
> infinite binary
> expansion 1.011001100110011001100..., "
> 
> Before such a number is prepared for display, the C standard 
> library for example does the rounding to a legible number.
> 
> So if you write
> 
>      printf( "%g\n", 7.0/5.0 );
> 
> you might get 1.4 as desired, but internally the number is 
> not correct.

I agree but decimal notation has exactly the same problem with other
numbers, e.g. 7/3. 

It's true to say that a decimal system can always accurately display the
decimal equivalent of a binary number, but the reverse isn't necessarily
true, and that therefore decimal systems can accurately represent more
numbers than binary.

> 
> Many years ago, I've been responsible for a development 
> system for business applications, which used floating-point 
> arithmetic, and we had error reports from customers that turned out
> as floating-point representation problems. Mind you, we've 
> been using only 2 decimal places.
> 
> And the number of calculations didn't matter either. 
> Sometimes after the first divison, and sometimes after 
> millions of computations, and the problem was 
> simply that a value has been used that could not be 
> represented properly as a floating-point number.
> 

If you are only using 2 decimal places then I can imagine such errors
occuring. The rule should always be to internally use somewhat greater
precision than you need to display externally, so that any rounding errors
nearly always remain invisible.

On a related topic, I recall with some amusement certain news reports in
1999, when the US' Dow Jones Industrial stock index was approaching a value
of 10,000. At that time obviously there were an abundance of Y2K fears, and
there was this story doing the rounds about the so-called "D10K bug".
Allegedly when the Dow exceeded 10,000 various computers tracking its
progress would think the value had suddenly dropped to near zero, and these
automated systems would frantically issue sell orders, plunging world stock
markets into the worse crash anyone has ever seen. These systems were
imagined to only be able to represent 4 digits of the Dow's value.

Of course, regardless of how much space programmers had allowed on screens
for the DJI, internally the applications most definitely did not use 4-digit
BCD representation. Inevitably when the Dow did eventually pass 10,000
nothing happened and equally inevitably, the media conveniently forgot about
the earlier scare stories.

------------------
Hans Summers
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/