Boost logo

Boost :

From: Paul Moore (gustav_at_[hidden])
Date: 2000-11-28 17:04:41


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.

> On the other hand, conversion from a string doesn't strike me
> as such a bad idea. Radix conversion is easy; it's parsing that's
> hard. If you're looking at a decimal string, it's easy to see
> that "0.1" is 1*10^-1.

Hm. I guess take the point. As long as we exclude exponential notation, it's
not too hard to do. But I still worry about edge conditions caused by
limited precision integers...

Can someone provide some real examples where a constructor from string is
really (really, really, truly :-) important? I don't want to start adding
"nice to haves" without a genuine benefit. And when you do, remember that
it's not hard to write it yourself if you need it - so why should it be part
of the class?

> If people are interested, I can extract the floating-point parsing
> code from the SGI I/O library.

Probably not necessary - unless exponential notation is important, it's not
too hard to do by hand.

Thanks,
Paul.


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