From: Tom Brinkman (reportbase_at_[hidden])
Date: 2008-06-02 11:04:02
>> I'm not even sure I understand the contract. How can you
>> round to a number of decimal places when the result is not
>> necessarily representable?
Good question. Not sure I have an answer. I just
evolved these algorithms becouse I couldnt find them anywhere
>> Rather than an implementation, could you
>> provide an example of a documentation, stating precisely what the
>> return value should be?
Sure. I could do that.
>> Also, if the intention is float/double/long
>> double, why templates, as opposed to three overloads? Thanks for any
Well, this is boost after all. What tradeoffs do you see?
>> Equally useful as rounding, perhaps, would be printing to a string
>> with guaranteed rounding. You know that printing or reading a binary
>> floating point to a decimal string representation, and back, may not
>> result in the same number. This goes with printf and scanf, as well
>> as I/O streams (perhaps this has been corrected but I haven't seen
>> anything very sophisticated in the STL implementations I lurk in).
>> There are known algorithms to do this with guaranteed rounding, e.g.:
I'm not an expert here. If you would be willing to advise me on
these issues, I might be persuaded to put together some
test cases and example files. I know there alot of subtle
issues involved with rounding floating point numbers.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk