bignum

0th

Percentile

Big number arithmetic

Basic operations for working with large integers. The bignum funtion converts a positive integer, string or raw vector into a bignum type. All basic Arithmetic and Comparison operators such as +, -, *, ^, %%, %/%, ==, !=, <, <=< code="">, > and >= are implemented for bignum objects.

Usage
bignum(x, hex = FALSE)
Arguments
x
an integer, string (hex or dec) or raw vector
hex
set to TRUE to parse strings as hex rather than decimal notation
Aliases
  • bignum
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)
Documentation reproduced from package openssl, version 0.6, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.