[TAG] Paul Sephton's article "A Question Of Rounding"
ben at linuxgazette.net
Thu Oct 4 01:11:37 MSD 2007
On Wed, Oct 03, 2007 at 10:59:43PM +0200, Paul Sephton wrote:
> On Wed, 2007-10-03 at 15:47 -0500, Ben Okopnik wrote:
> > On Wed, Oct 03, 2007 at 10:04:15PM +0200, Ren???? Pfeiffer wrote:
> > >
> > > Floating point numbers aren't exact.
> > [blink] Pardon my ignorance, but... what's the use of them, then?
> > Particularly since the rounding can happen (essentially arbitrarily) in
> > any direction?
> FP numbers are extremely useful for performing calcs very accurately.
> Yes, there's a loss in accuracy with calcs, but they are still very
> convenient. Rounding is always consistent according to the currently
> selected IEEE rounding mode which averages out error.
Ah. That makes sense. I was visualizing long calculations where the
inaccuracy just kept building up.
> Effectively, as
> long as you need less than 16 significant decimals you are cooking.
No trouble for me - I usually get along with three.
> > Also, given the above, _is_ there a way of producing a meaningful
> > fixed-point part of a number with precision?
> Yes, there is a way to produce a meaningful fixed point representation
> from the IEEE binary as per the code listing in the article.
As long as you use C, that is. :) Thanks, Paul!
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
More information about the TAG