|
Boost : |
From: Moore, Paul (paul.moore_at_[hidden])
Date: 2000-11-29 05:45:46
From: John (EBo) David [mailto:ebo_at_[hidden]]
> examples? Ok, this is one that I am thinking about -- and you may all
> fee free to tell me I'm being stupid if you think that it is so.
Thanks, these are useful.
[...]
> In both cases all my data (patch vertices, stem maps,
> canopy dimensions, seed size and dispersal trajectories)
> are all given to me in floating point format. I have no
> options on this one.
>
> So at this point I would ask the assembled crew: Isn't
> using rationals appropriate at this point, and if so what
> is the best method of converting to rational.
The common thread to all of the cases I have seen is input data in floating
point, but calculations want to be exact. And maybe output in floating
point, as well.
OK, I can see this. My view is that converting float->rational is therefore
an "application specific" operation, in that only the application developer
can say what tradeoffs are appropriate between accuracy and "readability"
(we've had an example where exact conversion was wanted, as well as yours
where "sensible values" were required). Therefore, I would say that a
constructor is wrong, as there is no common answer, but making conversion
functions available is sensible.
But it should be noted that the conversion functions may not cover all
possible bases, and for odd cases, it may be necessary for
application-specific conversion code to be written (hopefully, by someone
versed in the complexities of floating point representation :-)
Paul.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk