.\" Copyright 2026 Andrew V.Kosteltsev (kx@radix-linux.su) .\" .\" .TH imul_mod 3 "September 14, 2026" "libmpu" "LibMPU Programmer's Manual" .SH NAME \fBimul_mod\fP \- unsigned modular multiplication .SH SYNOPSIS .nf .B #include .PP .BI "void imul_mod( mpu_int *" c ", mpu_int *" a ", mpu_int *" b ", mpu_int *" m ", int " nb " );" .fi .SH DESCRIPTION The \fBimul_mod()\fP function performs unsigned modular multiplication .sp .nf c = (a * b) mod m .fi .sp and places the result at address \fBc\fP. The product is evaluated with sufficient intermediate precision so that it is not truncated to \fBnb\fP bytes before the modular reduction. The memory contents at addresses \fBa\fP, \fBb\fP and \fBm\fP are not changed. The \fBnb\fP parameter determines the size of all operands, in bytes. .PP If \fBm\fP is zero, the value at \fBc\fP is not changed, the \fBV\fP (Invalid operation) flag is set, and \fB__mpu_integer_error_no\fP is set to \fB__I_ENUMBER__\fP. .PP On successful completion the \fBZ\fP flag is set when the modular product is zero. .sp .SH EXAMPLES .nf .sp #include #include int main( void ) { mpu_int1024_t c, a, b, m; int nb = NB_I1024; __mpu_char8_t s[4096]; __mpu_init(); iatoui( a, "200", nb ); iatoui( b, "201", nb ); iatoui( m, "251", nb ); imul_mod( c, a, b, m, nb ); iuitoa( s, c, RADIX_DEC, LOWERCASE, nb ); printf( "c = %s;\\n", s ); /* c = 40; */ __mpu_free_context(); return( 0 ); } .fi .sp .SH SEE ALSO .BR iadd(3), .BR isub(3), .BR iadc(3), .BR isbb(3), .BR ineg(3), .BR inot(3), .BR iand(3), .BR itest(3), .BR icmp(3), .BR ior(3), .BR ixor(3), .BR iinc(3), .BR idec(3), .BR ixchg(3), .BR icpy(3), .BR icvt(3), .BR imul(3), .BR ismul(3), .BR idiv(3), .BR isdiv(3), .BR iatoi(3), .BR iatoui(3), .BR iitoa(3), .BR iuitoa(3), .BR _int_digs(3), .BR ibits_len(3), .BR igcd(3), .BR ilcm(3), .BR imod(3), .BR ipow_mod(3), .BR ipowm1_mod(3), .BR shifts(3), .BR shifts\-n(3), .BR circular\-shifts(3), .BR circular\-shifts\-n(3), .BR integer\-flags(3), .BR real\-flags(3), .BR libmpu(7).