Boost logo

Boost :

Subject: Re: [boost] New Boost.XInt Library, request preliminary review
From: Chad Nelson (chad.thecomfychair_at_[hidden])
Date: 2010-04-03 18:08:40

Hash: SHA1

On 04/02/2010 09:56 PM, Jeffrey Lee Hellrung, Jr. wrote:

> You seem to really want some kind of one-to-one identification between
> integers and xint::integer objects,

Well, yes -- the xint::integer objects represent integers, after all. ;-)

> but I implore you to step back a moment and relax that requirement.
> Your implementation naturally suggests two representations of zero,
> and I'm arguing to keep those distinct representations available for
> derived/wrapper classes, and for simplicity of implementation. I
> have yet to see where this makes a difference in the core interface
> or complicates the internal implementation.

It would a bit, because there may be code in there that assumes that if
the negative Boolean is true, the value is less than zero.

>> To make a sensible signed-zero value work, I'd have to make up portions
>> of the math, or adopt them from floating-point stuff even though that
>> doesn't make sense here.
> I don't know what you mean here. Isn't the arithmetic involving zeros
> fairly straightforward, signed or not?

If the zeros aren't signed, yes. If they are, and the library is
supposed to honor the signs, things could get hairy. But it appears that
I misunderstood your intentions... if a negative zero is still treated
as zero, then all the math works out.

>> The aforementioned arbitrary-precision floating point package will just
>> have to handle that itself, maybe by making an extremely small but
>> non-zero value and calling it negative zero.
> *That* seems "messy and arbitrary" ;)

It might be, it would depend on the design goals of the library.

You've convinced me not to dismiss the idea out of hand. I'm still not
sure that it's worthwhile, but I'll probably add it, with the
understanding that any calculations done with it (except a unary minus)
will come out with a positive-zero result. If someone needs a negative
zero, they'll have to explicitly request it via the unary minus.
- --
Chad Nelson
Oak Circle Software, Inc.
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


Boost list run by bdawes at, gregod at, cpdaniel at, john at