Date: 2001-10-20 06:53:23
--- In boost_at_y..., "Moore, Paul" <paul.moore_at_a...> wrote:
> From: brianjparker_at_h...
> > Just a quick note concerning the rational class- I see in the
> > documentation that it was decided not to provide a rational
> > approximation (from double) function as part of the library.
> > A good public domain implementation of such a function that I have
> > used previously is at
> > http://www.netlib.org/c/frac
> > It allows one to provide a relative error bound on the
> > It is in K&R C, but is easily convertible to C++ (just change the
> > prototype and remove the fabs() declaration).
It is C from syntax, but looks like FORTRAN from style,
IMHO it is not really convertible to C++.
> When this discussion came up before, people came up with lots of
> opinions, and a number of proposed algorithms. I don't have an
> myself, and I don't have the expertise to evaluate the options. As
> rather avoid any impression of "sanctioning" any particular
> So I think I'll continue ducking this issue, and leave the link out.
I agree that there is no "best" way of forming a rational
number from a floating point.
In particular, I agree that this conversion should
not be part of the rational number header.
OTOH, I see need for such conversion functions.
I found one Python implementation at
which I like very much.
I made a first translation to C++
and tested it with rational<int> and rational<big_int>.
If there is interest, I can completey boostify it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk