{
    "content": [
        {
            "type": "text",
            "text": "# bigint (man)\n\n## NAME\n\nbigint - Transparent BigInteger support for Perl\n\n## SYNOPSIS\n\nuse bigint;\n$x = 2 + 4.5,\"\\n\";                    # BigInt 6\nprint 2  512,\"\\n\";                  # really is what you think it is\nprint inf + 42,\"\\n\";                  # inf\nprint NaN * 7,\"\\n\";                   # NaN\nprint hex(\"0x1234567890123490\"),\"\\n\"; # Perl v5.10.0 or later\n{\nno bigint;\nprint 2  256,\"\\n\";                # a normal Perl scalar now\n}\n# Import into current package:\nuse bigint qw/hex oct/;\nprint hex(\"0x1234567890123490\"),\"\\n\";\nprint oct(\"01234567890123490\"),\"\\n\";\n\n## DESCRIPTION\n\nAll operators (including basic math operations) except the range operator \"..\"  are\noverloaded. Integer constants are created as proper BigInts.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (12 subsections)\n- **CAVEATS**\n- **MODULES USED**\n- **EXAMPLES**\n- **BUGS**\n- **SUPPORT**\n- **LICENSE**\n- **SEE ALSO**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "bigint",
        "section": "",
        "mode": "man",
        "summary": "bigint - Transparent BigInteger support for Perl",
        "synopsis": "use bigint;\n$x = 2 + 4.5,\"\\n\";                    # BigInt 6\nprint 2  512,\"\\n\";                  # really is what you think it is\nprint inf + 42,\"\\n\";                  # inf\nprint NaN * 7,\"\\n\";                   # NaN\nprint hex(\"0x1234567890123490\"),\"\\n\"; # Perl v5.10.0 or later\n{\nno bigint;\nprint 2  256,\"\\n\";                # a normal Perl scalar now\n}\n# Import into current package:\nuse bigint qw/hex oct/;\nprint hex(\"0x1234567890123490\"),\"\\n\";\nprint oct(\"01234567890123490\"),\"\\n\";",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Some cool command line examples to impress the Python crowd ;) You might want to compare them",
            "to the results under -Mbignum or -Mbigrat:",
            "perl -Mbigint -le 'print sqrt(33)'",
            "perl -Mbigint -le 'print 2*255'",
            "perl -Mbigint -le 'print 4.5+2*255'",
            "perl -Mbigint -le 'print 3/7 + 5/7 + 8/3'",
            "perl -Mbigint -le 'print 123->isodd()'",
            "perl -Mbigint -le 'print log(2)'",
            "perl -Mbigint -le 'print 2  0.5'",
            "perl -Mbigint=a,65 -le 'print 2  0.2'",
            "perl -Mbignum=a,65,l,GMP -le 'print 7  7777'"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 9,
                "subsections": [
                    {
                        "name": "use integer vs. use bigint",
                        "lines": 30
                    },
                    {
                        "name": "Options",
                        "lines": 57
                    },
                    {
                        "name": "Math Library",
                        "lines": 25
                    },
                    {
                        "name": "Internal Format",
                        "lines": 9
                    },
                    {
                        "name": "Sign",
                        "lines": 8
                    },
                    {
                        "name": "Method calls",
                        "lines": 34
                    },
                    {
                        "name": "Methods",
                        "lines": 1
                    },
                    {
                        "name": "inf()",
                        "lines": 3
                    },
                    {
                        "name": "NaN()",
                        "lines": 14
                    },
                    {
                        "name": "bexp()",
                        "lines": 10
                    },
                    {
                        "name": "bpi()",
                        "lines": 9
                    },
                    {
                        "name": "upgrade()",
                        "lines": 15
                    }
                ]
            },
            {
                "name": "CAVEATS",
                "lines": 58,
                "subsections": []
            },
            {
                "name": "MODULES USED",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "bigint - Transparent BigInteger support for Perl\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use bigint;\n\n$x = 2 + 4.5,\"\\n\";                    # BigInt 6\nprint 2  512,\"\\n\";                  # really is what you think it is\nprint inf + 42,\"\\n\";                  # inf\nprint NaN * 7,\"\\n\";                   # NaN\nprint hex(\"0x1234567890123490\"),\"\\n\"; # Perl v5.10.0 or later\n\n{\nno bigint;\nprint 2  256,\"\\n\";                # a normal Perl scalar now\n}\n\n# Import into current package:\nuse bigint qw/hex oct/;\nprint hex(\"0x1234567890123490\"),\"\\n\";\nprint oct(\"01234567890123490\"),\"\\n\";\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "All operators (including basic math operations) except the range operator \"..\"  are\noverloaded. Integer constants are created as proper BigInts.\n\nFloating point constants are truncated to integer. All parts and results of expressions are\nalso truncated.\n\nUnlike integer, this pragma creates integer constants that are only limited in their size by\nthe available memory and CPU time.\n",
                "subsections": [
                    {
                        "name": "use integer vs. use bigint",
                        "content": "There is one small difference between \"use integer\" and \"use bigint\": the former will not\naffect assignments to variables and the return value of some functions. \"bigint\" truncates\nthese results to integer too:\n\n# perl -Minteger -wle 'print 3.2'\n3.2\n# perl -Minteger -wle 'print 3.2 + 0'\n3\n# perl -Mbigint -wle 'print 3.2'\n3\n# perl -Mbigint -wle 'print 3.2 + 0'\n3\n\n# perl -Mbigint -wle 'print exp(1) + 0'\n2\n# perl -Mbigint -wle 'print exp(1)'\n2\n# perl -Minteger -wle 'print exp(1)'\n2.71828182845905\n# perl -Minteger -wle 'print exp(1) + 0'\n2\n\nIn practice this makes seldom a difference as parts and results of expressions will be\ntruncated anyway, but this can, for instance, affect the return value of subroutines:\n\nsub threeinteger { use integer; return 3.2; }\nsub threebigint { use bigint; return 3.2; }\n\nprint threeinteger(), \" \", threebigint(),\"\\n\";    # prints \"3.2 3\"\n"
                    },
                    {
                        "name": "Options",
                        "content": "bigint recognizes some options that can be passed while loading it via use.  The options can\n(currently) be either a single letter form, or the long form.  The following options exist:\n\na or accuracy\nThis sets the accuracy for all math operations. The argument must be greater than or equal\nto zero. See Math::BigInt's bround() function for details.\n\nperl -Mbigint=a,2 -le 'print 12345+1'\n\nNote that setting precision and accuracy at the same time is not possible.\n\np or precision\nThis sets the precision for all math operations. The argument can be any integer. Negative\nvalues mean a fixed number of digits after the dot, and are <B>ignored</B> since all\noperations happen in integer space.  A positive value rounds to this digit left from the\ndot. 0 or 1 mean round to integer and are ignore like negative values.\n\nSee Math::BigInt's bfround() function for details.\n\nperl -Mbignum=p,5 -le 'print 123456789+123'\n\nNote that setting precision and accuracy at the same time is not possible.\n\nt or trace\nThis enables a trace mode and is primarily for debugging bigint or Math::BigInt.\n\nhex\nOverride the built-in hex() method with a version that can handle big integers. This\noverrides it by exporting it to the current package. Under Perl v5.10.0 and higher, this is\nnot so necessary, as hex() is lexically overridden in the current scope whenever the bigint\npragma is active.\n\noct\nOverride the built-in oct() method with a version that can handle big integers. This\noverrides it by exporting it to the current package. Under Perl v5.10.0 and higher, this is\nnot so necessary, as oct() is lexically overridden in the current scope whenever the bigint\npragma is active.\n\nl, lib, try or only\nLoad a different math lib, see \"Math Library\".\n\nperl -Mbigint=lib,GMP -e 'print 2  512'\nperl -Mbigint=try,GMP -e 'print 2  512'\nperl -Mbigint=only,GMP -e 'print 2  512'\n\nCurrently there is no way to specify more than one library on the command line. This means\nthe following does not work:\n\nperl -Mbignum=l,GMP,Pari -e 'print 2  512'\n\nThis will be hopefully fixed soon ;)\n\nv or version\nThis prints out the name and version of all modules used and then exits.\n\nperl -Mbigint=v\n"
                    },
                    {
                        "name": "Math Library",
                        "content": "Math with the numbers is done (by default) by a module called Math::BigInt::Calc. This is\nequivalent to saying:\n\nuse bigint lib => 'Calc';\n\nYou can change this by using:\n\nuse bignum lib => 'GMP';\n\nThe following would first try to find Math::BigInt::Foo, then Math::BigInt::Bar, and when\nthis also fails, revert to Math::BigInt::Calc:\n\nuse bigint lib => 'Foo,Math::BigInt::Bar';\n\nUsing \"lib\" warns if none of the specified libraries can be found and Math::BigInt did fall\nback to one of the default libraries.  To suppress this warning, use \"try\" instead:\n\nuse bignum try => 'GMP';\n\nIf you want the code to die instead of falling back, use \"only\" instead:\n\nuse bignum only => 'GMP';\n\nPlease see respective module documentation for further details.\n"
                    },
                    {
                        "name": "Internal Format",
                        "content": "The numbers are stored as objects, and their internals might change at anytime, especially\nbetween math operations. The objects also might belong to different classes, like\nMath::BigInt, or Math::BigInt::Lite. Mixing them together, even with normal scalars is not\nextraordinary, but normal and expected.\n\nYou should not depend on the internal format, all accesses must go through accessor methods.\nE.g. looking at $x->{sign} is not a good idea since there is no guaranty that the object in\nquestion has such a hash key, nor is a hash underneath at all.\n"
                    },
                    {
                        "name": "Sign",
                        "content": "The sign is either '+', '-', 'NaN', '+inf' or '-inf'.  You can access it with the sign()\nmethod.\n\nA sign of 'NaN' is used to represent the result when input arguments are not numbers or as a\nresult of 0/0. '+inf' and '-inf' represent plus respectively minus infinity. You will get\n'+inf' when dividing a positive number by 0, and '-inf' when dividing any negative number by\n0.\n"
                    },
                    {
                        "name": "Method calls",
                        "content": "Since all numbers are now objects, you can use all functions that are part of the BigInt API.\nYou can only use the bxxx() notation, and not the fxxx() notation, though.\n\nBut a warning is in order. When using the following to make a copy of a number, only a\nshallow copy will be made.\n\n$x = 9; $y = $x;\n$x = $y = 7;\n\nUsing the copy or the original with overloaded math is okay, e.g. the following work:\n\n$x = 9; $y = $x;\nprint $x + 1, \" \", $y,\"\\n\";     # prints 10 9\n\nbut calling any method that modifies the number directly will result in both the original and\nthe copy being destroyed:\n\n$x = 9; $y = $x;\nprint $x->badd(1), \" \", $y,\"\\n\";        # prints 10 10\n\n$x = 9; $y = $x;\nprint $x->binc(1), \" \", $y,\"\\n\";        # prints 10 10\n\n$x = 9; $y = $x;\nprint $x->bmul(2), \" \", $y,\"\\n\";        # prints 18 18\n\nUsing methods that do not modify, but test that the contents works:\n\n$x = 9; $y = $x;\n$z = 9 if $x->iszero();                # works fine\n\nSee the documentation about the copy constructor and \"=\" in overload, as well as the\ndocumentation in BigInt for further details.\n"
                    },
                    {
                        "name": "Methods",
                        "content": ""
                    },
                    {
                        "name": "inf()",
                        "content": "A shortcut to return Math::BigInt->binf(). Useful because Perl does not always handle\nbareword \"inf\" properly.\n"
                    },
                    {
                        "name": "NaN()",
                        "content": "A shortcut to return Math::BigInt->bnan(). Useful because Perl does not always handle\nbareword \"NaN\" properly.\n\ne\n# perl -Mbigint=e -wle 'print e'\n\nReturns Euler's number \"e\", aka exp(1). Note that under bigint, this is truncated to an\ninteger, and hence simple '2'.\n\nPI\n# perl -Mbigint=PI -wle 'print PI'\n\nReturns PI. Note that under bigint, this is truncated to an integer, and hence simple '3'.\n"
                    },
                    {
                        "name": "bexp()",
                        "content": "bexp($power,$accuracy);\n\nReturns Euler's number \"e\" raised to the appropriate power, to the wanted accuracy.\n\nNote that under bigint, the result is truncated to an integer.\n\nExample:\n\n# perl -Mbigint=bexp -wle 'print bexp(1,80)'\n"
                    },
                    {
                        "name": "bpi()",
                        "content": "bpi($accuracy);\n\nReturns PI to the wanted accuracy. Note that under bigint, this is truncated to an integer,\nand hence simple '3'.\n\nExample:\n\n# perl -Mbigint=bpi -wle 'print bpi(80)'\n"
                    },
                    {
                        "name": "upgrade()",
                        "content": "Return the class that numbers are upgraded to, is in fact returning $Math::BigInt::upgrade.\n\nineffect()\nuse bigint;\n\nprint \"in effect\\n\" if bigint::ineffect;       # true\n{\nno bigint;\nprint \"in effect\\n\" if bigint::ineffect;     # false\n}\n\nReturns true or false if \"bigint\" is in effect in the current scope.\n\nThis method only works on Perl v5.9.4 or later.\n"
                    }
                ]
            },
            "CAVEATS": {
                "content": "Operator vs literal overloading\n\"bigint\" works by overloading handling of integer and floating point literals, converting\nthem to Math::BigInt objects.\n\nThis means that arithmetic involving only string values or string literals will be\nperformed using Perl's built-in operators.\n\nFor example:\n\nuse bignum;\nmy $x = \"900000000000000009\";\nmy $y = \"900000000000000007\";\nprint $x - $y;\n\nwill output 0 on default 32-bit builds, since \"bigint\" never sees the string literals.  To\nensure the expression is all treated as \"Math::BigInt\" objects, use a literal number in the\nexpression:\n\nprint +(0+$x) - $y;\n\nranges\nPerl does not allow overloading of ranges, so you can neither safely use ranges with bigint\nendpoints, nor is the iterator variable a bigint.\n\nuse 5.010;\nfor my $i (12..13) {\nfor my $j (20..21) {\nsay $i  $j;  # produces a floating-point number,\n# not a big integer\n}\n}\n\nineffect()\nThis method only works on Perl v5.9.4 or later.\n\nhex()/oct()\n\"bigint\" overrides these routines with versions that can also handle big integer values.\nUnder Perl prior to version v5.9.4, however, this will not happen unless you specifically\nask for it with the two import tags \"hex\" and \"oct\" - and then it will be global and cannot\nbe disabled inside a scope with \"no bigint\":\n\nuse bigint qw/hex oct/;\n\nprint hex(\"0x1234567890123456\");\n{\nno bigint;\nprint hex(\"0x1234567890123456\");\n}\n\nThe second call to hex() will warn about a non-portable constant.\n\nCompare this to:\n\nuse bigint;\n\n# will warn only under Perl older than v5.9.4\nprint hex(\"0x1234567890123456\");\n",
                "subsections": []
            },
            "MODULES USED": {
                "content": "\"bigint\" is just a thin wrapper around various modules of the Math::BigInt family. Think of\nit as the head of the family, who runs the shop, and orders the others to do the work.\n\nThe following modules are currently used by bigint:\n\nMath::BigInt::Lite      (for speed, and only if it is loadable)\nMath::BigInt\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "Some cool command line examples to impress the Python crowd ;) You might want to compare them\nto the results under -Mbignum or -Mbigrat:\n\nperl -Mbigint -le 'print sqrt(33)'\nperl -Mbigint -le 'print 2*255'\nperl -Mbigint -le 'print 4.5+2*255'\nperl -Mbigint -le 'print 3/7 + 5/7 + 8/3'\nperl -Mbigint -le 'print 123->isodd()'\nperl -Mbigint -le 'print log(2)'\nperl -Mbigint -le 'print 2  0.5'\nperl -Mbigint=a,65 -le 'print 2  0.2'\nperl -Mbignum=a,65,l,GMP -le 'print 7  7777'\n",
                "subsections": []
            },
            "BUGS": {
                "content": "For information about bugs and how to report them, see the BUGS section in the documentation\navailable with the perldoc command.\n\nperldoc bignum\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "You can find documentation for this module with the perldoc command.\n\nperldoc bigint\n\nFor more information, see the SUPPORT section in the documentation available with the perldoc\ncommand.\n\nperldoc bignum\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This program is free software; you may redistribute it and/or modify it under the same terms\nas Perl itself.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "bignum and bigrat.\n\nMath::BigInt, Math::BigFloat, Math::BigRat and Math::Big as well as Math::BigInt::FastCalc,\nMath::BigInt::Pari and Math::BigInt::GMP.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "•   (C) by Tels <http://bloodgate.com/> in early 2002 - 2007.\n\n•   Maintained by Peter John Acklam <pjacklam@gmail.com<gt>, 2014-.\n\n\n\nperl v5.34.0                                 2025-07-25                                bigint(3perl)",
                "subsections": []
            }
        }
    }
}