Boost logo

Boost :

Subject: Re: [boost] New Boost.XInt Library, request preliminary review
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2010-04-06 11:54:50

Kim Barrett wrote:
> On Apr 3, 2010, at 9:03 PM, Jeffrey Lee Hellrung, Jr. wrote:
>> Chad Nelson wrote:
>>> 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. ;-)
>> Yes, and IEEE floats represent (limited precision and limited range) dyadic rationals. My point is, it can be practical and efficient to have 2 different underlying representations for the same abstract instance. You're already carrying around a sign bit + mantissa to represent an integer, so it seems to me unnatural to bend over backwards (exaggeration) to keep that sign bit unset when the mantissa drops to 0, if you really don't have to.
> To me, the key question is whether the signed 0 shows through the interface. I would consider it a mistake if it did so. Besides any "purity" arguments, doing so would eliminate the option of using some otherwise plausible internal representation, such as 2s-complement (*). The fact that the implementation presently under the discussion happens to be signed-magnitude should not be driving the interface. And if the signed 0 doesn't show through the interface, then why are we having this discussion at all.
> (*) That's not just a theoretical possibility; several of the (non-C++) unbounded integer packages I've had occasion to do some work on or look at in detail over my career used a 2s-complement internal representation.

Good point. Do you have any references to such packages? I'm curious
about the implementation advantages and disadvantages of using
2s-complement vs sign+magnitude.

- Jeff

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