Small toom43 cleanup

Niels Möller nisse at
Wed Oct 21 08:42:12 CEST 2009

bodrato at writes:

> Does the compiler know that (bn-1) is unsigned positive? I do not
> think so...

It doesn't. But in an operation like a / b where operands have
different types, the value of the "smaller" type is utomatically
promoted to the "larger" type.

If you have different bitsize, say unsigned short and long int,
operands will be promoted to the larger type. If you have you have a
signed and unsigned type of the same bit size (int and unsigned, or
long and unsigned long), the unsigned type is considered "larger" and
it's the type that is used for the operation.

So as long as size_t is at least as many bits as mp_size_t, it should
be an unsigned divide.

But it might be clearer to the reader to cast both operands to size_t.


More information about the gmp-devel mailing list