mpi division truncation mode

D. Hugh Redelmeier hugh@mimosa.com
Tue, 26 Oct 1999 12:58:58 -0400 (EDT)


As I've mentioned, I'm trying to wean dsa.c, elgamal.c, and primegen.c
from mpi.h

My current theory is that every mpi number used in gcrypt is non-negative.
Is this correct?  If so, could the mpi code be simplified?

(Perhaps it is even the case that all mpi numbers in gcrypt are
actually representatives members of a finite ring of integers mod
something.)

I've noticed that every mpi divide I've come across uses "f" (floor)
rounding (towards -infinity).  Except for one in primegen.c:is_prime -- it
uses mpi_tdiv_q_2exp.  "t" (truncate) rounds towards 0.  If the numbers
concerned are never negative, then this is a distinction without a
difference.

This is just idle curiosity -- how I learn things.

Hugh Redelmeier
hugh@mimosa.com  voice: +1 416 482-8253