Marco Bodrato bodrato at mail.dm.unipi.it
Fri Nov 30 16:20:24 UTC 2018

Ciao Vincent,

Il Ven, 30 Novembre 2018 4:24 pm, Vincent Lefevre ha scritto:
> With the correct signs:
> #define GMP_NEG_CAST(T,x) (((T) -((x) + 1)) + 1)

Of course, you are right. (I messed up the e-mail a little bit, and sent
the intended message as an attachment...)

> but I still don't see any advantage.

Well, -((x) + 1) is computed as a signed type, and avoids the possible
issue of representing -LONG_MIN with signed. Moreover -((x) + 1) is non
negative, so that there are no problems in casting it to an unsigned type.
Paul did not use a cast in his code, so he had to use the -(x + 1) form.

I understand this version better than the one we have in the code...

Anyway, if someone can suggest the most _portable_ way to define the
macro, we can change its definition (both in mini- and in GMP).



More information about the gmp-devel mailing list