Algorithm::AM::BigInt - Helper functions for AM big integers
version 3.12
use Algorithm::AM::BigInt 'bigcmp'; # get some big integers from Algorithm::AM::Result my ($a, $b); bigcmp($a, $b);
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.
Under the hood, the big integers used by AM are scalars with the following fields:
This is an inexact double representation of the integer value.
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.
printf
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.
Theron Stanford <shixilun@yahoo.com>, Nathan Glenn <garfieldnate@gmail.com>
This software is copyright (c) 2021 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.
To install Algorithm::AM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::AM
CPAN shell
perl -MCPAN -e shell install Algorithm::AM
For more information on module installation, please visit the detailed CPAN module installation guide.