{
    "content": [
        {
            "type": "text",
            "text": "# bigint (perldoc)\n\n## NAME\n\nbigint - transparent big integer support for Perl\n\n## SYNOPSIS\n\nuse bigint;\n$x = 2 + 4.5;                       # Math::BigInt 6\nprint 2  512;                     # Math::BigInt 134...096\nprint inf + 42;                     # Math::BigInt inf\nprint NaN * 7;                      # Math::BigInt NaN\nprint hex(\"0x1234567890123490\");    # Perl v5.10.0 or later\n{\nno bigint;\nprint 2  256;                 # a normal Perl scalar now\n}\n# for older Perls, import into current package:\nuse bigint qw/hex oct/;\nprint hex(\"0x1234567890123490\");\nprint oct(\"01234567890123490\");\n\n## DESCRIPTION\n\nAll numeric literal in the given scope are converted to Math::BigInt objects. Numeric literal\nthat represent non-integers are truncated to an integer. All results of expressions are also\ntruncated to integer.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (12 subsections)\n- **CAVEATS** (2 subsections)\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": "perldoc",
        "summary": "bigint - transparent big integer support for Perl",
        "synopsis": "use bigint;\n$x = 2 + 4.5;                       # Math::BigInt 6\nprint 2  512;                     # Math::BigInt 134...096\nprint inf + 42;                     # Math::BigInt inf\nprint NaN * 7;                      # Math::BigInt NaN\nprint hex(\"0x1234567890123490\");    # Perl v5.10.0 or later\n{\nno bigint;\nprint 2  256;                 # a normal Perl scalar now\n}\n# for older Perls, import into current package:\nuse bigint qw/hex oct/;\nprint hex(\"0x1234567890123490\");\nprint oct(\"01234567890123490\");",
        "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 -Mbigfloat or -Mbigrat:",
            "perl -Mbigint -le 'print sqrt(33)'",
            "perl -Mbigint -le 'print 2255'",
            "perl -Mbigint -le 'print 4.5+2255'",
            "perl -Mbigint -le 'print 123->isodd()'",
            "perl -Mbigint=l,GMP -le 'print 7  7777'"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 77,
                "subsections": [
                    {
                        "name": "Options",
                        "lines": 47
                    },
                    {
                        "name": "Math Library",
                        "lines": 25
                    },
                    {
                        "name": "Method calls",
                        "lines": 34
                    },
                    {
                        "name": "Methods",
                        "lines": 1
                    },
                    {
                        "name": "inf",
                        "lines": 18
                    },
                    {
                        "name": "bexp",
                        "lines": 10
                    },
                    {
                        "name": "bpi",
                        "lines": 9
                    },
                    {
                        "name": "accuracy",
                        "lines": 2
                    },
                    {
                        "name": "precision",
                        "lines": 2
                    },
                    {
                        "name": "round_mode",
                        "lines": 2
                    },
                    {
                        "name": "div_scale",
                        "lines": 2
                    },
                    {
                        "name": "in_effect",
                        "lines": 12
                    }
                ]
            },
            {
                "name": "CAVEATS",
                "lines": 37,
                "subsections": [
                    {
                        "name": "in_effect",
                        "lines": 2
                    },
                    {
                        "name": "hex",
                        "lines": 22
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "bigint - transparent big integer support for Perl\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use bigint;\n\n$x = 2 + 4.5;                       # Math::BigInt 6\nprint 2  512;                     # Math::BigInt 134...096\nprint inf + 42;                     # Math::BigInt inf\nprint NaN * 7;                      # Math::BigInt NaN\nprint hex(\"0x1234567890123490\");    # Perl v5.10.0 or later\n\n{\nno bigint;\nprint 2  256;                 # a normal Perl scalar now\n}\n\n# for older Perls, import into current package:\nuse bigint qw/hex oct/;\nprint hex(\"0x1234567890123490\");\nprint oct(\"01234567890123490\");\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "All numeric literal in the given scope are converted to Math::BigInt objects. Numeric literal\nthat represent non-integers are truncated to an integer. All results of expressions are also\ntruncated to integer.\n\nAll operators (including basic math operations) except the range operator \"..\" are overloaded.\n\nUnlike the integer pragma, the \"bigint\" pragma creates integers that are only limited in their\nsize by the available memory.\n\nSo, the following:\n\nuse bigint;\n$x = 1234;\n\ncreates a Math::BigInt and stores a reference to in $x. This happens transparently and behind\nyour back, so to speak.\n\nYou can see this with the following:\n\nperl -Mbigint -le 'print ref(1234)'\n\nSince numbers are actually objects, you can call all the usual methods from Math::BigFloat on\nthem. This even works to some extent on expressions:\n\nperl -Mbigint -le '$x = 1234; print $x->bdec()'\nperl -Mbigint -le 'print 1234->copy()->binc();'\nperl -Mbigint -le 'print 1234->copy()->binc->badd(6);'\nperl -Mbigint -le 'print +(1234)->copy()->binc()'\n\n(Note that print doesn't do what you expect if the expression starts with '(' hence the \"+\")\n\nYou can even chain the operations together as usual:\n\nperl -Mbigint -le 'print 1234->copy()->binc->badd(6);'\n1241\n\nPlease note the following does not work as expected (prints nothing), since overloading of '..'\nis not yet possible in Perl (as of v5.8.0):\n\nperl -Mbigint -le 'for (1..2) { print ref($); }'\n\nuse integer vs. use bigint\nThere are some difference between \"use integer\" and \"use bigint\".\n\nWhereas \"use integer\" is limited to what can be handled as a Perl scalar, \"use bigint\" can\nhandle arbitrarily large integers.\n\nAlso, \"use integer\" does affect assignments to variables and the return value of some functions.\n\"use bigint\" truncates these results to integer:\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 seldom makes a difference for small integers as parts and results of\nexpressions are truncated anyway, but this can, for instance, affect the return value of\nsubroutines:\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",
                "subsections": [
                    {
                        "name": "Options",
                        "content": "\"bigint\" recognizes some options that can be passed while loading it via \"use\". The following\noptions 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() method 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 ignored since all operations\nhappen in integer space. A positive value rounds to this digit left from the dot. 0 means\nround to integer. See Math::BigInt's bfround() method for details.\n\nperl -mbigint=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.\n\nl, lib, try, or only\nLoad a different math lib, see \"Math Library\".\n\nperl -Mbigint=l,GMP -e 'print 2  512'\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\nhex Override the built-in hex() method with a version that can handle big numbers. This\noverrides it by exporting it to the current package. Under Perl v5.10.0 and higher, this is\nnot necessary, as hex() is lexically overridden in the current scope whenever the \"bigint\"\npragma is active.\n\noct Override the built-in oct() method with a version that can handle big numbers. 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\n\"bigint\" pragma is active.\n\nv or version\nthis prints out the name and version of the modules and then exits.\n\nperl -Mbigint=v\n"
                    },
                    {
                        "name": "Math Library",
                        "content": "Math with the numbers is done (by default) by a backend library module called\nMath::BigInt::Calc. The default is equivalent to saying:\n\nuse bigint lib => 'Calc';\n\nyou can change this by using:\n\nuse bigint lib => 'GMP';\n\nThe following would first try to find Math::BigInt::Foo, then Math::BigInt::Bar, and if this\nalso fails, revert to Math::BigInt::Calc:\n\nuse bigint lib => 'Foo,Math::BigInt::Bar';\n\nUsing c<lib> warns if none of the specified libraries can be found and Math::BigInt fell back to\none of the default libraries. To suppress this warning, use c<try> instead:\n\nuse bigint try => 'GMP';\n\nIf you want the code to die instead of falling back, use \"only\" instead:\n\nuse bigint only => 'GMP';\n\nPlease see the respective module documentation for further details.\n"
                    },
                    {
                        "name": "Method calls",
                        "content": "Since all numbers are now objects, you can use all methods that are part of the Math::BigInt\nAPI.\n\nBut a warning is in order. When using the following to make a copy of a number, only a shallow\ncopy 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 Math::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\nNaN()\nA 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, i.e., 2.\n\nPI\n# perl -Mbigint=PI -wle 'print PI'\n\nReturns PI. Note that under \"bigint\", this is truncated to an integer, i.e., 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\ninteger, i.e., 3.\n\nExample:\n\n# perl -Mbigint=bpi -wle 'print bpi(80)'\n"
                    },
                    {
                        "name": "accuracy",
                        "content": "Set or get the accuracy.\n"
                    },
                    {
                        "name": "precision",
                        "content": "Set or get the precision.\n"
                    },
                    {
                        "name": "round_mode",
                        "content": "Set or get the rounding mode.\n"
                    },
                    {
                        "name": "div_scale",
                        "content": "Set or get the division scale.\n"
                    },
                    {
                        "name": "in_effect",
                        "content": "use 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": "Hexadecimal, octal, and binary floating point literals\nPerl (and this module) accepts hexadecimal, octal, and binary floating point literals, but\nuse them with care with Perl versions before v5.32.0, because some versions of Perl silently\ngive the wrong result.\n\nOperator 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 are performed\nusing Perl's built-in operators.\n\nFor example:\n\nuse bigint;\nmy $x = \"900000000000000009\";\nmy $y = \"900000000000000007\";\nprint $x - $y;\n\noutputs 0 on default 32-bit builds, since \"bigint\" never sees the string literals. To ensure\nthe 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\n\"bigint\" endpoints, nor is the iterator variable a \"Math::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 an object\n}\n}\n",
                "subsections": [
                    {
                        "name": "in_effect",
                        "content": "This method only works on Perl v5.9.4 or later.\n"
                    },
                    {
                        "name": "hex",
                        "content": "\"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"
                    }
                ]
            },
            "EXAMPLES": {
                "content": "Some cool command line examples to impress the Python crowd ;) You might want to compare them to\nthe results under -Mbigfloat or -Mbigrat:\n\nperl -Mbigint -le 'print sqrt(33)'\nperl -Mbigint -le 'print 2255'\nperl -Mbigint -le 'print 4.5+2255'\nperl -Mbigint -le 'print 123->isodd()'\nperl -Mbigint=l,GMP -le 'print 7  7777'\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Please report any bugs or feature requests to \"bug-bignum at rt.cpan.org\", or through the web\ninterface at <https://rt.cpan.org/Ticket/Create.html?Queue=bignum> (requires login). We will be\nnotified, and then you'll automatically be notified of progress on your bug as I make changes.\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "You can find documentation for this module with the perldoc command.\n\nperldoc bigint\n\nYou can also look for information at:\n\n*   GitHub\n\n<https://github.com/pjacklam/p5-bignum>\n\n*   RT: CPAN's request tracker\n\n<https://rt.cpan.org/Dist/Display.html?Name=bignum>\n\n*   MetaCPAN\n\n<https://metacpan.org/release/bignum>\n\n*   CPAN Testers Matrix\n\n<http://matrix.cpantesters.org/?dist=bignum>\n\n*   CPAN Ratings\n\n<https://cpanratings.perl.org/dist/bignum>\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "This program is free software; you may redistribute it and/or modify it under the same terms as\nPerl 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>, 2014-.\n",
                "subsections": []
            }
        }
    }
}