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:55:30


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

On 04/03/2010 07:49 AM, Paul A. Bristow wrote:

(I'm not sure who this one was addressed to, but I'll answer it anyway.) :-)

>>> 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?
>
> IMO this is computing - whatever mathematicians feel about it.
>
> 1 There *really is a sign bit*, so either we should ensure that it is
> never set with zero (which *might* involve some runtime cost - if we
> negate a value, so we have to check for zero?) or just accept
> acknowledge that it is there ?

At the moment, that's handled in the cleanup code. If the number is only
one digit in length, and that digit is zero, then it automatically clear
the negative bit. So yes, it involves a (very small) runtime cost.

> 2 Is it relevant that that floating point types have sign and
> copysign functions that might be applied by some generic code to this
> 'user-defined' type? Would be simplest for these to be provided and
> to do the obvious thing? Or are we saying that this can't be used in
> this way?

Sorry, I don't understand. This isn't a floating-point type, so generic
code shouldn't assume that it can be treated as such. I do plan to add a
numeric_limits for it (as you suggested), which will clearly identify it
as an integral type for generic code.

> 3 Likewise there *really is a limit to the size of this infinite
> sized integer*, and many users will want to place an arbitrary limit
> on its size (and to know that that is). "Calculate Fib numbers, but
> don't use more than 1 Mbyte for it".

That's fairly easy to do at the user level, for those who want it.

> 4 Some users may also want to limit the size to some chosen fixed
> arbitrary maximum number that is much smaller in order to mimic some
> of the fixed big integers about (128 bit, 256 bit, 100 decimal digits
> like NTL ZZ type etc). Would it be logical to provide the
> std::numeric_limits<integer>::max() function for this? And what
> about the std::numeric_limits digits and digits10()?

Such a thing could easily be done by creating a wrapper around (or
subclass of) xint::integer.

> All these decisions seem to me arbitrary and pragmatic. Perhaps we
> should leave the author to make a full proposal with some use case
> and provide a rationale and pros and cons.

I'll do my best. :-)
- --
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/

iEYEARECAAYFAku3x2IACgkQp9x9jeZ9/wQrowCgwKtC0cmfAEmcuZNdnECwfmiB
DXIAnjd3FRSwm640K+D9aedu7GzR+v3c
=p75f
-----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