{
    "content": [
        {
            "type": "text",
            "text": "# bigint (info)\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\noperator \"..\"  are overloaded. Integer constants are created as proper\nBigInts.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\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": "info",
        "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": 258,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 60,
                "subsections": []
            },
            {
                "name": "MODULES USED",
                "lines": 9,
                "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": 5,
                "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\noperator \"..\"  are overloaded. Integer constants are created as proper\nBigInts.\n\nFloating point constants are truncated to integer. All parts and\nresults of expressions are also truncated.\n\nUnlike integer, this pragma creates integer constants that are only\nlimited in their size by the available memory and CPU time.\n\nuse integer vs. use bigint\nThere is one small difference between \"use integer\" and \"use bigint\":\nthe former will not affect assignments to variables and the return\nvalue of some functions. \"bigint\" truncates these results to integer\ntoo:\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\nexpressions will be truncated anyway, but this can, for instance,\naffect 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\nOptions\nbigint recognizes some options that can be passed while loading it via\nuse.  The options can (currently) be either a single letter form, or\nthe long form.  The following options exist:\n\na or accuracy\nThis sets the accuracy for all math operations. The argument must be\ngreater than or equal to zero. See Math::BigInt's bround() function\nfor details.\n\nperl -Mbigint=a,2 -le 'print 12345+1'\n\nNote that setting precision and accuracy at the same time is not\npossible.\n\np or precision\nThis sets the precision for all math operations. The argument can be\nany integer. Negative values mean a fixed number of digits after the\ndot, and are <B>ignored</B> since all operations happen in integer\nspace.  A positive value rounds to this digit left from the dot. 0 or\n1 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\npossible.\n\nt or trace\nThis enables a trace mode and is primarily for debugging bigint or\nMath::BigInt.\n\nhex\nOverride the built-in hex() method with a version that can handle big\nintegers. This overrides it by exporting it to the current package.\nUnder Perl v5.10.0 and higher, this is not so necessary, as hex() is\nlexically overridden in the current scope whenever the bigint pragma\nis active.\n\noct\nOverride the built-in oct() method with a version that can handle big\nintegers. This overrides it by exporting it to the current package.\nUnder Perl v5.10.0 and higher, this is not so necessary, as oct() is\nlexically overridden in the current scope whenever the bigint pragma\nis 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\ncommand line. This means the 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\nexits.\n\nperl -Mbigint=v\n\nMath Library\nMath with the numbers is done (by default) by a module called\nMath::BigInt::Calc. This is equivalent 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\nMath::BigInt::Bar, and when this also fails, revert to\nMath::BigInt::Calc:\n\nuse bigint lib => 'Foo,Math::BigInt::Bar';\n\nUsing \"lib\" warns if none of the specified libraries can be found and\nMath::BigInt did fall back to one of the default libraries.  To\nsuppress this warning, use \"try\" instead:\n\nuse bignum try => 'GMP';\n\nIf you want the code to die instead of falling back, use \"only\"\ninstead:\n\nuse bignum only => 'GMP';\n\nPlease see respective module documentation for further details.\n\nInternal Format\nThe numbers are stored as objects, and their internals might change at\nanytime, especially between math operations. The objects also might\nbelong to different classes, like Math::BigInt, or Math::BigInt::Lite.\nMixing them together, even with normal scalars is not extraordinary,\nbut normal and expected.\n\nYou should not depend on the internal format, all accesses must go\nthrough accessor methods. E.g. looking at $x->{sign} is not a good idea\nsince there is no guaranty that the object in question has such a hash\nkey, nor is a hash underneath at all.\n\nSign\nThe sign is either '+', '-', 'NaN', '+inf' or '-inf'.  You can access\nit with the sign() method.\n\nA sign of 'NaN' is used to represent the result when input arguments\nare not numbers or as a result of 0/0. '+inf' and '-inf' represent plus\nrespectively minus infinity. You will get '+inf' when dividing a\npositive number by 0, and '-inf' when dividing any negative number by\n0.\n\nMethod calls\nSince all numbers are now objects, you can use all functions that are\npart of the BigInt API. You can only use the bxxx() notation, and not\nthe fxxx() notation, though.\n\nBut a warning is in order. When using the following to make a copy of a\nnumber, only a shallow 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\nfollowing 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\nboth the original and the 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,\nas well as the documentation in BigInt for further details.\n\nMethods\ninf()\nA shortcut to return Math::BigInt->binf(). Useful because Perl does\nnot always handle bareword \"inf\" properly.\n\nNaN()\nA shortcut to return Math::BigInt->bnan(). Useful because Perl does\nnot always handle bareword \"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\nis truncated to an integer, 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,\nand hence simple '3'.\n\nbexp()\nbexp($power,$accuracy);\n\nReturns Euler's number \"e\" raised to the appropriate power, to the\nwanted 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\nbpi()\nbpi($accuracy);\n\nReturns PI to the wanted accuracy. Note that under bigint, this is\ntruncated to an integer, and hence simple '3'.\n\nExample:\n\n# perl -Mbigint=bpi -wle 'print bpi(80)'\n\nupgrade()\nReturn the class that numbers are upgraded to, is in fact returning\n$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",
                "subsections": []
            },
            "CAVEATS": {
                "content": "Operator vs literal overloading\n\"bigint\" works by overloading handling of integer and floating point\nliterals, converting them to Math::BigInt objects.\n\nThis means that arithmetic involving only string values or string\nliterals will be performed 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\nstring literals.  To ensure the expression is all treated as\n\"Math::BigInt\" objects, use a literal number in the expression:\n\nprint +(0+$x) - $y;\n\nranges\nPerl does not allow overloading of ranges, so you can neither safely\nuse ranges with bigint endpoints, nor is the iterator variable a\nbigint.\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\nbig integer values. Under Perl prior to version v5.9.4, however, this\nwill not happen unless you specifically ask for it with the two\nimport 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\nMath::BigInt family. Think of it as the head of the family, who runs\nthe 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\nmight want to compare them to 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\nin the documentation available 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\navailable with the perldoc command.\n\nperldoc bignum\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This program is free software; you may redistribute it and/or modify it\nunder the same terms as Perl itself.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "bignum and bigrat.\n\nMath::BigInt, Math::BigFloat, Math::BigRat and Math::Big as well as\nMath::BigInt::FastCalc, Math::BigInt::Pari and Math::BigInt::GMP.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "o   (C) by Tels <http://bloodgate.com/> in early 2002 - 2007.\n\no   Maintained by Peter John Acklam <pjacklam@gmail.com<gt>, 2014-.\n\nperl v5.34.0                      2026-06-23                     bigint(3perl)",
                "subsections": []
            }
        }
    }
}