|
Boost : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-10-19 02:23:10
Just a quick query about what you guys think should be done in overflow
situations with high-precision arithmetic in the preprocessor library. I
have three options:
1) return a known (and detectable) error state
2) saturate at the greatest value
3) cause a glorious preprocessor failure
I don't like Option 1 very much because nobody is actually going to check
for overflow, and I can't afford the cost of doing the check inside the
implementation so I can propogate the error state.
Option 2 uses saturation arithmetic like the current library arithmetic
does. (I.e. any attempt to increase above +9,999,999,999 results in
+9,999,999,999, and any attempt to decrease below -9,999,999,999 results
in -9,999,999,999.)
Option 3 is the most efficient and overflow currently won't happen unless an
attempt is made to go past positive or negative 9,999,999,999.
Thanks in advance for any comments.
Paul Mensonides
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk