|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2005-09-07 06:39:42
"Joel Eidsath" <jeidsath_at_[hidden]> wrote in message
news:431E4A69.9020805_at_gmail.com...
>
>>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. Floats, doubles and so on hold rational numbers, not
> irrationals, not integers.
>
> Now, are you seriously claiming, as the first poster did, that
> boost::rational will work whenever you need an arbitrary precision
> rational number? Or do you have some other point? I really fail to see
> what you are trying to get at.
>
> 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.)
It is your useage of the word "rational number" that I am arguing with. Its
misleading because ( I think) you are using it to mean an arbitrary precision
floating point number representation of a real value rather than its proper
sense. see e.g:
http://mathworld.wolfram.com/RationalNumber.html
OTOH, if you are using the term correctly then there is no such concept as
"setting the precision of a rational number", because a generic rational number
has exactly one representation ( eg as a fraction).
The examples you have given eg:
"
rational a,b;
a.set_precision(50); //a's precision now set at 50
b.set_precision(150) //b's precision now set at 150, a's precision.
"
make no sense for rational numbers, because they are not generically
representable in floating point of any but infinite precision.
Perhaps an alternative name to 'rational' for your type would be less confusing.
regards
Andy Little
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk