# man > bignum(3pm)

---
type: CommandReference
command: bignum
mode: man
section: 3perl
source: man-pages
---

## Quick Reference
- `perl -Mbignum -le 'print 2**512 * 0.1'` — BigFloat precision
- `perl -Mbignum -le 'print inf * inf'` — handles infinity
- `perl -Mbignum -le 'print 1234+4.5'` — automatic integer→float upgrade
- `perl -Mbignum=a,50 -le 'print sqrt(20)'` — set accuracy
- `perl -Mbignum=p,-50 -le 'print sqrt(20)'` — set precision
- `perl -Mbignum=l,GMP -le 'print 2**512'` — use GMP math library
- `perl -Mbignum=PI -wle 'print PI'` — constant π
- `perl -Mbignum=e -wle 'print e'` — constant *e*

## Name
bignum — Transparent BigNumber support for Perl

## Synopsis
perl
use bignum;                      # all numeric constants become BigInt/BigFloat
$x = 2 + 4.5;                    # $x is Math::BigFloat 6.5
print 2 ** 512 * 0.1;            # large numbers and floats work
print inf * inf;                 # infinity support
print NaN * 3;                   # NaN support

{
    no bignum;                   # lexically disable
    print 2 ** 256;              # normal Perl scalar
}

# For older Perls, override hex/oct in current package
use bignum qw/hex oct/;
print hex("0x1234567890123456");
print oct("01234567890123456");
## Options
Options are passed at `use` time.

- `-a`, `accuracy` — Accuracy (digits after decimal). Example: `use bignum a => 50;`
- `-p`, `precision` — Precision (place value). Negative = digits after dot, positive = left of dot. Example: `use bignum p => -5;`
- `-t`, `trace` — Enable debugging trace mode.
- `-l`, `lib` — Backend math library. Default is `Calc`. Use `lib => 'GMP'`, `try => 'GMP'`, or `only => 'GMP'`.
- `hex` — Export a big‑number‑aware **hex()**. Lexically overridden on Perl ≥ 5.10.0.
- `oct` — Export a big‑number‑aware **oct()**. Lexically overridden on Perl ≥ 5.10.0.
- `-v`, `version` — Print module versions and exit.

### Functions
These are shortcuts to [Math::BigInt](http://localhost/phpMan.php/perldoc/Math%3A%3ABigInt/markdown)/[Math::BigFloat](http://localhost/phpMan.php/perldoc/Math%3A%3ABigFloat/markdown) methods:

- `inf()` — Returns `Math::BigInt->binf()` (positive infinity)
- `NaN()` — Returns `Math::BigInt->bnan()` (not‑a‑number)
- `e` — Euler’s number
- `PI()` — π
- `bexp($power, $accuracy)` — *e* raised to `$power` with given accuracy
- `bpi($accuracy)` — π to the given accuracy
- `upgrade()` — Returns the class numbers are upgraded to (e.g., [Math::BigFloat](http://localhost/phpMan.php/perldoc/Math%3A%3ABigFloat/markdown))
- `in_effect()` — True if `bignum` pragma active in the current scope (Perl ≥ 5.9.4)

## Examples
shell
perl -Mbignum -le 'print sqrt(33)'
perl -Mbignum -le 'print 2*255'
perl -Mbignum -le 'print 4.5+2*255'
perl -Mbignum -le 'print 3/7 + 5/7 + 8/3'
perl -Mbignum -le 'print 123->is_odd()'
perl -Mbignum -le 'print log(2)'
perl -Mbignum -le 'print exp(1)'
perl -Mbignum -le 'print 2 ** 0.5'
perl -Mbignum=a,65 -le 'print 2 ** 0.2'
perl -Mbignum=a,65,l,GMP -le 'print 7 ** 7777'
## See Also
- [bigint](http://localhost/phpMan.php/man/bigint/3perl)
- [bigrat](http://localhost/phpMan.php/man/bigrat/3perl)
- [Math::BigInt](http://localhost/phpMan.php/perldoc/Math%3A%3ABigInt/markdown)
- [Math::BigFloat](http://localhost/phpMan.php/perldoc/Math%3A%3ABigFloat/markdown)
- [Math::BigRat](http://localhost/phpMan.php/perldoc/Math%3A%3ABigRat/markdown)
- [Math::Big](http://localhost/phpMan.php/perldoc/Math%3A%3ABig/markdown)
- [Math::BigInt::FastCalc](http://localhost/phpMan.php/perldoc/Math%3A%3ABigInt%3A%3AFastCalc/markdown)
- [Math::BigInt::Pari](http://localhost/phpMan.php/perldoc/Math%3A%3ABigInt%3A%3APari/markdown)
- [Math::BigInt::GMP](http://localhost/phpMan.php/perldoc/Math%3A%3ABigInt%3A%3AGMP/markdown)