Boost logo

Boost :

From: Andras Erdei (aerdei_at_[hidden])
Date: 2005-09-07 02:22:19


On 9/7/05, Joel Eidsath <jeidsath_at_[hidden]> wrote:

> >My point is that floating point representation of a number is in no way a
> peer
> >concept of rational number. IOW your assertion :
> >
> >"Examples of basic rational number types in C++: float, double, etc."
> >
> Rational numbers are a mathematical concept, not a computer science
> concept.

it is a CS concept as well

if you are interested, a good text on representing numbers
as rationals (num/den pairs) is Matula-Kornerup: Foundations
of Finite Precision Rational Arithmetic, Computing Suppl. 2,
1980, pp 85-111

Floats, doubles and so on hold rational numbers, not
> irrationals, not integers.

yes, but they are only capable of holding rationals with
power-of-two denominators, which is a severe limitation

Now, are you seriously claiming, as the first poster did, that
> boost::rational will work whenever you need an arbitrary precision
> rational number?

not the current implementation, as it has no rounding

Or do you have some other point?

i think he is suggesting that radix representation may
be good (efficient etc) for integers, but is certainly
not a good way to represent non-integers

num/den pairs are much better, and there are several
other alternatives (representations based on exponential
functions, continued fraction expansions, composition of
linear fractional transformations etc)

The only point that you seemed to be trying to make with your examples
> was that "boost::rational has it's place too..." Again, I fail to see
> what that has to do with the discussion at hand. No one has said
> anything different. (That place is just not an arbitrary precision
> library rational class. For example, notice the calls to gcd() in the
> constructor. You're toast as soon as you start dealing with large primes.)

with the current boost::rational, yes, but with a
rounding implementation, no

br,
andras


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk