From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-02-28 09:18:38
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Kevin Atkinson
> Sent: Friday, February 28, 2003 1:23 AM
> To: Boost mailing list
> Subject: RE: [boost] Is there any Interest in a Fixed Point Library?
> Why on earth didn't the language include fixed point and/or
> fractional types?
> Well in order for fractions to be really useful, that is to support exact
> values for basic arithmetic, you would also need a arbitrary size integer
> class as the numerator and denominator can get very large very fast unless
> the fraction is automatically reduces after each operation and even than
> the numbers can get big.
Long ago I used a language when programmers were men and 16 bits and 8 kbytes
was all you got. The 16 bit fractional type was very neat for holding lots of
measurements, but it was all too easy, as with your proposal, to fall into
over/underflow pits and calculation was usually best done using floating point.
> > As you observe, the increased accuracy compared to float (just a little too
> > small for some measurements like weights) but with half the memory
> of double,
> > and of course the integer/binary nature are sometimes useful.
> I am curious why you say a float is "just a little too small for some
> measurements like weights". I have always used doubles, but I never put
> much thought into it.
Only that float is usually good for about 6 decimal digits, but a lab balance
can easily weigh more decimal digits. So if you weigh the beaker and then the
beaker plus stuff, you end up with little or no accuracy for the weight of
stuff. For embedded systems without FPU, using doubles may be less attractive
Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk