[Aldor-l] Using GMP and extending the biging protocol

Stephen Watt watt at scl.csd.uwo.ca
Sat Aug 16 12:29:18 EDT 2008


Off-hand that looks broken.  -- Stephen

On Sat, Aug 16, 2008 at 12:24 PM,  <pip88nl at gmail.com> wrote:
> 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
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFIpv8mJc+zqGNdDgoRAqqmAKCtBCWKJ282poHNp0FS/nnjwEdMGQCfY9FQ
> PNwlci7J+dE3EQHfU2/g4jw=
> =2BwZ
> -----END PGP SIGNATURE-----
>
>



More information about the Aldor-l mailing list