[Aldor-l] Using GMP and extending the biging protocol
pip88nl at gmail.com
pip88nl at gmail.com
Sat Aug 16 12:24:06 EDT 2008
On Sat, Aug 16, 2008 at 12:02:33AM -0400, Stephen Watt wrote:
> The bigint macros are supposed to use the 2's complement overflows for
> the purposes of good, not evil :).
>
> That is, there are places where they are supposed to happen and we
> count on the overflows wrapping around. This is used, for example, in
> testing for carries. It allows us to use full word arithmetic from
> C.
Is this one of the places where it's supposed to overflow:
/*
* Allocate a new, stored integer value.
*/
BInt
xintStoreI(long n)
{
BInt b;
ULong u;
IInt a;
u = (n < 0) ? -n : n; // <-- here it overflows
for (a = 1; ; a += 1, u >>= BINT_LG_RADIX)
if( u < BINT_RADIX ) break;
b = bintAllocPlaces(a);
return xintCopyInI(b, n);
}
for LONG_MIN, nothing happens there. -n == n for LONG_MIN. Is this right?
Pippijn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.aldor.org/pipermail/aldor-l_aldor.org/attachments/20080816/7fc09bfe/attachment-0002.bin>
More information about the Aldor-l
mailing list