Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Math::GMP

Native Rust implementation built into the interpreter. Runtime: PP. See original documentation for the full Perl reference.

Math::GMP — High-speed arbitrary precision integers

This is the Perl-facing frontend for Peta::FFI::GMP. It:

  1. Triggers Peta::FFI::GMP::register() to load libgmp and wire up all ops
  2. Registers the overloaded operators for the Math::GMP class
  3. Implements Math::GMP::new() with its argument parsing logic
  4. Registers aliases: gcd → bgcd, lcm → blcm, DESTROY → destroy

All arithmetic, comparison, and utility functions are already registered under Math::GMP::* by Peta::FFI::GMP::register(), so we only add the Perl-level glue here.

Functions

new

Constructs a new Math::GMP object from a string, integer, or existing Math::GMP.

use Math::GMP;
my $n = Math::GMP->new("123456789012345678901234567890");
my $hex = Math::GMP->new("ff", 16);

See also: new_from_scalar, new_from_scalar_with_base, gmp_copy