Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

modulus

Modulus of a Big Integer


Description

The modulus of a bigz number a is “unset” when a is a regular integer, a \in Z). Or the modulus can be set to m which means a in Z/mZ), i.e., all arithmetic with a is performed ‘modulo m’.

Usage

modulus(a)
modulus(a) <- value

Arguments

a

R object of class "bigz"

value

integer number or object of class "bigz".

Examples

x <- as.bigz(24)
modulus(x) # NULL, i.e. none

# x element of Z/31Z :
modulus(x) <- 31
x+x  #  48 |-> (17 %% 31)
10*x # 240 |-> (23 %% 31)
x31 <- x

# reset modulus to "none":
modulus(x) <- NA; x; x. <- x
x <- x31
modulus(x) <- NULL; x

stopifnot(identical(x,            as.bigz(24)), identical(x, x.),
          identical(modulus(x31), as.bigz(31)))

gmp

Multiple Precision Arithmetic

v0.6-2
GPL (>= 2)
Authors
Antoine Lucas, Immanuel Scholz, Rainer Boehme <rb-gmp@reflex-studio.de>, Sylvain Jasson <Sylvain.Jasson@inrae.fr>, Martin Maechler <maechler@stat.math.ethz.ch>
Initial release
2021-01-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.