Boost logo

Boost :

Subject: Re: [boost] New Boost.XInt Library, request preliminary review
From: Chad Nelson (chad.thecomfychair_at_[hidden])
Date: 2010-04-02 15:10:27


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/02/2010 02:32 PM, Jeffrey Hellrung wrote:

> Don't forget (assuming a single unsigned 0):
>
> x / 0 => NaN

Eh? I thought we'd decided that anything divided by zero, other than
zero itself, was infinity (or negative infinity, if x is negative)?

> and I think you'd want Inf to compare equal with itself (unlike NaN,
> which does not compare equal with itself...and doesn't compare unequal
> with itself, either :/ ).

Yes, the infinity values will be comparable to anything (except NaN, of
course), and will do what you logically expect them to.

> This is of secondary consideration to the core set of algorithms that
> should just throw whenever something bad happens (e.g., division by 0),
> though.

Of course. :-)

> Another topic: Chad, how natural is it, implementation-wise, to have a
> signed zero? I'm guessing you have a sign bit, leading naturally to
> either providing both a +0 or a -0, or ensuring after each operation
> that -0 is normalized to +0.

It wouldn't be a problem to implement it, and yes, I do have a sign bit
(or rather, a sign Boolean, but that's essentially the same thing).

> What are the arguments against a signed zero?

That there's no need for it in an integer library. I may have gotten
some things wrong, but I don't think anyone refuted that part. Quoting
from my earlier message on the subject:

- ----------------8<----------------
Forgive any mathematical terminology errors, I'm only an armchair
mathematician. But in the domain of natural numbers, zero, by
definition, has no sign. It's neither positive nor negative (or if you
prefer, it's both). Signed zero seems to be an invention of computer
science, where it represents a fraction that's so small that the inexact
computer representation is indistinguishable from zero, but where the
number itself isn't necessarily true zero.
- ----------------8<----------------

As such, there's no real need for it in XInt.

> Is it possible to simply be agnostic to the sign bit when the
> mantissa is 0?

Isn't that the same as saying that -0 is identical to +0?
- --
Chad Nelson
Oak Circle Software, Inc.
*
*
*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAku2QSMACgkQp9x9jeZ9/wR6VgCfeIu9Kjt1ZEAwMBXpHLGs1vX/
VdkAoKxtlp4xAHxknrlg+OKB5QQMjSwA
=xi4n
-----END PGP SIGNATURE-----


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk