Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-11-28 17:25:23

At 10:04 PM 11/28/2000 +0000, Paul Moore wrote:

>From: austern_at_[hidden]
>> It seems to me that what people are really asking for is an
>> algorithm, given a rational number p and an integer N, for
>> finding the closest rational number q whose denominator is
>> no greater than N. That's a generally useful algorithm; it
>> shouldn't be hidden away inside a constructor, and there
>> should never be an implied value for N. (Because only the
>> user knows what the appropriate value for N is.)
>Quite possibly. That's exactly what Reggie Seagraves kindly supplied. If
>there is a general feeling that this would be worth including, I am happy

>to do so.

It seems to me Matt's solution (of not providing a constructor from double,
but separately providing an algorithm) is a really good way to:

1) prevent people from inadvertently shooting themselves in the foot, but
2) still providing the facility for those who are willing to risk it.

My initial reaction is to package the conversion algorithm in rational.hpp,
but as a non-member function. The separation is intended to emphasize that
this isn't some everyday member function to be used without conscious
thought, but it is there if needed.

The docs should include rationale as to why it is done that way.


Boost list run by bdawes at, gregod at, cpdaniel at, john at