|
Boost : |
From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-10-21 12:38:15
At Monday 2002/10/21 08:21, fernando_cacciola_at_[hidden] wrote:
>----- Original Message -----
>From: "Paul Mensonides" <pmenso57_at_[hidden]>
>To: "Boost Developers" <boost_at_[hidden]>
>Sent: Saturday, October 19, 2002 4:23 AM
>Subject: [boost] Boost.Preprocessor - High-Precision Arithmetic Query
>
>
> > 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 think that the only truly useful options are (3) or [1+2].
>That is, either (1) or (2)[or any variance of 2] alone are useless.
[deleted]
>Writing a *robust* program in the absence of signaling overflow is almost
>impossible.
>How would you correctly implement something as naive as this:
>
>int a_number = <...>;
>
>int the_opposite = -a_number ;
>
>Most programmers are not aware that if "a_number" is the bit pattern
>'1000....'
>(0x800...), then "the_opposite==a_number".
>I've seen this sort of bug totally ruin many numerical algorithms.
>
>The real problem in the case above is that 2's-complement masks the overflow
>when converting
>from the minimum negative value to the maximum positive value
>(the positive range has one element less);
>
>So, I think this is one of the things that we should *not* inherit from C.
I concur It's nice to see someone else who knows that C' claim "you can
code right down to the sand" isn't in one to one correspondence with reality.
I think I miss the ability to detect 'carry' more than 'overflow' tho
>It is OK to return a fake result (say a saturated number) but only as long
>as the user can tell so.
>If it is impractical to signal the overflow along with the saturated result,
>then the operation
>should fail.\
Agreed
>Fernando Cacciola
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
"There oughta be a law"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk