minor noises made by gcc and -std=iso9899:1999 with -Wall -pedantic -Wextra -pedantic-errors

Torbjörn Granlund tg at gmplib.org
Mon Jul 1 12:40:24 UTC 2019


Vincent Lefevre <vincent at vinc17.net> writes:

  However the GMP code is poorly written.

    mp_size_t n = 1 + (2 * an >= 3 * bn ? (an - 1) / (size_t) 3 : (bn - 1) >> 1);

  What's the point of the cast to size_t?

It is a slight performance optimisation.

  Moreover, GMP favors signed arithmetic with a signed type mp_size_t,
  thus artificially switching to unsigned arithmetic with this cast is
  a bad idea.

Why?  We have full control of the ranges of the involved variables.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-discuss mailing list