mikefc

Rationale

This is a toy library written in order bootstrap another idea, without having to carry a dependency on a real arbitrary precision library like gmp or Rmpfr.

The algorithms are straight-forward implementations of naive algorithms and are orders of magnitute slower than gmp even for small/moderate sized integers.

Installation

devtools::install_github('coolbutuseless/tapir')

Supported data types

The only supported datatype is an unsigned integer represented in a character string. e.g.

  • “1234”
  • “9237409238740928374029374293”

Supported operations

  • %add% - Addition
  • %sub% - Subtration
  • %sub% - Multiplication
  • %div% - Division
  • %mod% - Modulo operator
  • Logical
    • %gt% - greater than
    • %gte% - greater than or equal to
    • %eq% - equal to
    • %lt% - less than
    • %lte% - less than or equal to

Helper functions

  • rbigint(digits)
    • Create a big integer with the given number of digits

Examples

a <- rbigint(30)
b <- rbigint(20)
a
[1] "452174481578156515482786118879"
b
[1] "14890841683199436406"
a %mul% b
[1] "6733258618363108716539967151530576651772916508874"
a %div% b
[1] "30365945135"
a %mod% b
[1] "12151378315268534069"
a %add% b
[1] "452174481593047357165985555285"
a %sub% b
[1] "452174481563265673799586682473"