Why am I getting the wrong output?

Torbjorn Granlund tg at gmplib.org
Sat Jul 14 19:29:58 CEST 2012


Shlomi Fish <shlomif at shlomifish.org> writes:

  GMP: 4444 % 52 ==  28
  [C]: 4444 % 52 ==  24
  
  Why?

Why not?  Did you expect something else?

  Is this a bug?
  
In GMP, you mean?  No, it computes the remainder exactly as documented.

I doubt the C remainder operator % is ddfined to do ceiling rounding on
any system.  It is certainly not required to do that, so your C compiler
is also DTRT.

-- 
Torbjörn


More information about the gmp-discuss mailing list