File: bignum.Rd

package info (click to toggle)
r-cran-openssl 2.3.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,336 kB
  • sloc: ansic: 3,158; sh: 20; makefile: 5
file content (49 lines) | stat: -rw-r--r-- 1,456 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bignum.R
\name{bignum}
\alias{bignum}
\alias{bignum_mod_exp}
\alias{bignum_mod_inv}
\title{Big number arithmetic}
\usage{
bignum(x, hex = FALSE)

bignum_mod_exp(a, b, m)

bignum_mod_inv(a, m)
}
\arguments{
\item{x}{an integer, string (hex or dec) or raw vector}

\item{hex}{set to TRUE to parse strings as hex rather than decimal notation}

\item{a}{bignum value for \code{(a^b \%\% m)}}

\item{b}{bignum value for \code{(a^b \%\% m)}}

\item{m}{bignum value for \code{(a^b \%\% m)}}
}
\description{
Basic operations for working with large integers. The \code{bignum}
function converts a positive integer, string or raw vector into a bignum type.
All basic \link{Arithmetic} and \link{Comparison} operators such as
\code{+}, \code{-}, \code{*}, \code{^}, \code{\%\%}, \code{\%/\%}, \code{==},
\code{!=}, \code{<}, \code{<=}, \code{>} and \code{>=} are implemented for
bignum objects. The
\href{https://en.wikipedia.org/wiki/Modular_exponentiation}{Modular exponent}
(\code{a^b \%\% m}) can be calculated using \code{\link[=bignum_mod_exp]{bignum_mod_exp()}}
when \code{b} is too large for calculating \code{a^b} directly.
}
\examples{
# create a bignum
x <- bignum(123L)
y <- bignum("123456789123456789")
z <- bignum("D41D8CD98F00B204E9800998ECF8427E", hex = TRUE)

# Basic arithmetic
div <- z \%/\% y
mod <- z \%\% y
z2 <- div * y + mod
stopifnot(z2 == z)
stopifnot(div < z)
}