|
Boost : |
Subject: Re: [boost] New Boost.XInt Library, request preliminary review
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-03-28 18:26:39
Chad Nelson wrote:
> On 03/28/2010 02:37 PM, Jeffrey Lee Hellrung, Jr. wrote:
>
[...]
>> NaNs might have a valid use case to simply represent indeterminates,
>> but it also might be convenient to guarantee that every xint::integer
>> object actually represents an actual integer. Seems simpler
>> (semantics, implementation) to just forego any NaN representation,
>> and throw on operations that produce indeterminate, complex, or
>> infinite results.
>
> Which would defeat the primary purpose of the NaN value in the XInt
> library, which is to have something to return instead of throwing an
> exception when exceptions are blocked. :-)
If that's the purpose of your NaN, why limit your set of "special"
values to just { NaN }, when under some circumstances returning some
representation of infinity (or +infinity or -infinity if you make such a
distinction) would be more informative? For example, you can make n/0
for n != 0 result in infinity, and 0/0 result in NaN.
> By the same token, specific infinity values aren't needed either. The
> library will represent, exactly, any value that it can access enough
> memory for, and will throw an exception on any value with a greater
> magnitude than that.
What if "exceptions are blocked" in this case? Do you return an NaN
here as well?
- Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk