NAME
Algorithm::AM::BigInt - Helper functions for AM big integers
VERSION
version 3.09
SYNOPSIS
use Algorithm::AM::BigInt 'bigcmp';
# get some big integers from Algorithm::AM::Result
my ($a, $b);
bigcmp($a, $b);
DESCRIPTION
AM uses custom 128-bit unsigned integers in its XS code, and these numbers cannot be treated normally in Perl code. This package provides some helper functions for working with these numbers.
DETAILS
Under the hood, the big integers used by AM are scalars with the following fields:
- NV
-
This is an inexact double representation of the integer value.
- PV
-
This is an exact string representation of the integer value.
Operations on the floating-point representation will necessarily have a small amount of error, so exact calculation or comparison requires referencing the string field. The number field is still useful in printing reports; for example, using printf
, where precision can be specified.
Currently, the only provided helper function is for comparison of two big integers.
bigcmp
Compares two big integers, returning 1, 0, or -1 depending on whether the first argument is greater than, equal to, or less than the second argument.
AUTHOR
Theron Sanford <shixilun@yahoo.com>, Nathan Glenn <garfieldnate@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Royal Skousen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.