Flusspferd API and module docs

class gmp.Integer

Description

Provides a bignum integer class. See gmp’s mpz_class for the C++ API that is wrapped.

Includes

Constructor

new gmp.Integer(value)
 new gmp.Integer(str, base)
  • value (Number | String | gmp.Base) – initial value
  • str (String) – value in a string
  • base (Number) – base to interpret str in

Construct a new GMP integer value, either from a primitive value, form an existing gmp.Base or via a string representation.

White space is allowed in str, and is simply ignored. If base is 0 then the leading characters are used: “0x” and “0X” for hexadecimal, “0b” and “0B” for binary, “0” for octal, or decimal otherwise.

For bases up to 36, case is ignored; upper-case and lower-case letters have the same value. For bases 37 to 62, upper-case letter represent the usual 10..35 while lower-case letter represent 36..61.

Instance methods

  • fitsInt #

    gmp.Integer#fitsInt() ⇒ Boolean

    Checks if the value fits into an integer.

  • getInt #

    gmp.Integer#getInt() ⇒ Integer

    Returns the value as an integer.

  • sqrt #

    gmp.Integer#sqrt() ⇒ gmp.Float

    Returns the square root of this.