> What is the purpose of GMP_NEG_CAST
  >
  > #define GMP_NEG_CAST(T,x) (-((T)((x) + 1) - 1))
  >
  > instead of just a cast followed by a negation? i.e.
  >
  >  mpz_set_ui (r, - (unsigned long int) x);

This is confusing.

1. We can never use this for signed types with negative values if T is
   unsigned.

2. For signed source types, the + 1 - 1 trickery might help for MIN_INT
   (etc) but will cause undefined behavious for MAX_INT (etc).

For unsigned source and destination types, things are fine, but any
plain expression will work fine.

For signed source to wider signed destination types, again any plain
expression should work fine.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to