From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2006-05-03 06:19:12
[mailto:boost-bounces_at_[hidden]] On Behalf Of Geoffrey Irving
Sent: 02 May 2006 18:01 To: boost_at_[hidden]
> On Tue, May 02, 2006 at 04:54:40PM +0200, Sebastian Redl wrote:
>> Paul A Bristow wrote:
>>> The Standard is imprecise on this issue, but I feel it is a very
>>> poor do that such a bizarre small range of values should be wrong.
>>> Feels like an off-by-one rounding bug to me.
>> I tend to agree with the MS engineers here. I've found out only
>> yesterday that the FPU/math library is not entirely deterministic in
>> some calculations (including square roots and trigonometry, typical
>> 3d stuff), so I think worrying about serialization/deserialization
>> is useless.
Actually, I don't think there are any non-deterministic maths
implementations out there - I suspect you mean "not entirely accurate".
> Do you have example code / pointers to documentation for that? I've
> always been under the impression that basic math is deterministic
> regardless of IEEE compliance, and would really like to know if/where
> there are cases where that doesn't hold.
As I said, I don't think non-deterministic implementations exist, but
probabilistic rounding apparently has some attractive features, and it
is certainly allowed by the standard. The idea is that you calculate
(in principle) the exact result, and round up the last bit with
probability equal to
(ExactValue - ValueWithLSBitRoundedDown) / ValueOfLastBit
(In practise of course you don't need to calculate an infinite number of
bits. You keep calculating extra bits until you get a bit that doesn't
match your random number generator bit stream. At that point you know
whether you need to round up or down - regardless of what all the other
bits from the value or the random number generator are).
-- Martin Bonner Martin.Bonner_at_[hidden] Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 203894
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk