{
    "mode": "perldoc",
    "parameter": "Math::BigFloat",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Math%3A%3ABigFloat/json",
    "generated": "2026-06-09T16:25:52Z",
    "synopsis": "use Math::BigFloat;\n# Configuration methods (may be used as class methods and instance methods)\nMath::BigFloat->accuracy();     # get class accuracy\nMath::BigFloat->accuracy($n);   # set class accuracy\nMath::BigFloat->precision();    # get class precision\nMath::BigFloat->precision($n);  # set class precision\nMath::BigFloat->roundmode();   # get class rounding mode\nMath::BigFloat->roundmode($m); # set global round mode, must be one of\n# 'even', 'odd', '+inf', '-inf', 'zero',\n# 'trunc', or 'common'\nMath::BigFloat->config(\"lib\");  # name of backend math library\n# Constructor methods (when the class methods below are used as instance\n# methods, the value is assigned the invocand)\n$x = Math::BigFloat->new($str);               # defaults to 0\n$x = Math::BigFloat->new('0x123');            # from hexadecimal\n$x = Math::BigFloat->new('0o377');            # from octal\n$x = Math::BigFloat->new('0b101');            # from binary\n$x = Math::BigFloat->fromhex('0xc.afep+3');  # from hex\n$x = Math::BigFloat->fromhex('cafe');        # ditto\n$x = Math::BigFloat->fromoct('1.3267p-4');   # from octal\n$x = Math::BigFloat->fromoct('01.3267p-4');  # ditto\n$x = Math::BigFloat->fromoct('0o1.3267p-4'); # ditto\n$x = Math::BigFloat->fromoct('0377');        # ditto\n$x = Math::BigFloat->frombin('0b1.1001p-4'); # from binary\n$x = Math::BigFloat->frombin('0101');        # ditto\n$x = Math::BigFloat->fromieee754($b, \"binary64\");  # from IEEE-754 bytes\n$x = Math::BigFloat->bzero();                 # create a +0\n$x = Math::BigFloat->bone();                  # create a +1\n$x = Math::BigFloat->bone('-');               # create a -1\n$x = Math::BigFloat->binf();                  # create a +inf\n$x = Math::BigFloat->binf('-');               # create a -inf\n$x = Math::BigFloat->bnan();                  # create a Not-A-Number\n$x = Math::BigFloat->bpi();                   # returns pi\n$y = $x->copy();        # make a copy (unlike $y = $x)\n$y = $x->asint();      # return as BigInt\n# Boolean methods (these don't modify the invocand)\n$x->iszero();          # if $x is 0\n$x->isone();           # if $x is +1\n$x->isone(\"+\");        # ditto\n$x->isone(\"-\");        # if $x is -1\n$x->isinf();           # if $x is +inf or -inf\n$x->isinf(\"+\");        # if $x is +inf\n$x->isinf(\"-\");        # if $x is -inf\n$x->isnan();           # if $x is NaN\n$x->ispositive();      # if $x > 0\n$x->ispos();           # ditto\n$x->isnegative();      # if $x < 0\n$x->isneg();           # ditto\n$x->isodd();           # if $x is odd\n$x->iseven();          # if $x is even\n$x->isint();           # if $x is an integer\n# Comparison methods\n$x->bcmp($y);           # compare numbers (undef, < 0, == 0, > 0)\n$x->bacmp($y);          # compare absolutely (undef, < 0, == 0, > 0)\n$x->beq($y);            # true if and only if $x == $y\n$x->bne($y);            # true if and only if $x != $y\n$x->blt($y);            # true if and only if $x < $y\n$x->ble($y);            # true if and only if $x <= $y\n$x->bgt($y);            # true if and only if $x > $y\n$x->bge($y);            # true if and only if $x >= $y\n# Arithmetic methods\n$x->bneg();             # negation\n$x->babs();             # absolute value\n$x->bsgn();             # sign function (-1, 0, 1, or NaN)\n$x->bnorm();            # normalize (no-op)\n$x->binc();             # increment $x by 1\n$x->bdec();             # decrement $x by 1\n$x->badd($y);           # addition (add $y to $x)\n$x->bsub($y);           # subtraction (subtract $y from $x)\n$x->bmul($y);           # multiplication (multiply $x by $y)\n$x->bmuladd($y,$z);     # $x = $x * $y + $z\n$x->bdiv($y);           # division (floored), set $x to quotient\n# return (quo,rem) or quo if scalar\n$x->btdiv($y);          # division (truncated), set $x to quotient\n# return (quo,rem) or quo if scalar\n$x->bmod($y);           # modulus (x % y)\n$x->btmod($y);          # modulus (truncated)\n$x->bmodinv($mod);      # modular multiplicative inverse\n$x->bmodpow($y,$mod);   # modular exponentiation (($x  $y) % $mod)\n$x->bpow($y);           # power of arguments (x  y)\n$x->blog();             # logarithm of $x to base e (Euler's number)\n$x->blog($base);        # logarithm of $x to base $base (e.g., base 2)\n$x->bexp();             # calculate e  $x where e is Euler's number\n$x->bnok($y);           # x over y (binomial coefficient n over k)\n$x->bsin();             # sine\n$x->bcos();             # cosine\n$x->batan();            # inverse tangent\n$x->batan2($y);         # two-argument inverse tangent\n$x->bsqrt();            # calculate square root\n$x->broot($y);          # $y'th root of $x (e.g. $y == 3 => cubic root)\n$x->bfac();             # factorial of $x (1*2*3*4*..$x)\n$x->blsft($n);          # left shift $n places in base 2\n$x->blsft($n,$b);       # left shift $n places in base $b\n# returns (quo,rem) or quo (scalar context)\n$x->brsft($n);          # right shift $n places in base 2\n$x->brsft($n,$b);       # right shift $n places in base $b\n# returns (quo,rem) or quo (scalar context)\n# Bitwise methods\n$x->band($y);           # bitwise and\n$x->bior($y);           # bitwise inclusive or\n$x->bxor($y);           # bitwise exclusive or\n$x->bnot();             # bitwise not (two's complement)\n# Rounding methods\n$x->round($A,$P,$mode); # round to accuracy or precision using\n# rounding mode $mode\n$x->bround($n);         # accuracy: preserve $n digits\n$x->bfround($n);        # $n > 0: round to $nth digit left of dec. point\n# $n < 0: round to $nth digit right of dec. point\n$x->bfloor();           # round towards minus infinity\n$x->bceil();            # round towards plus infinity\n$x->bint();             # round towards zero\n# Other mathematical methods\n$x->bgcd($y);            # greatest common divisor\n$x->blcm($y);            # least common multiple\n# Object property methods (do not modify the invocand)\n$x->sign();              # the sign, either +, - or NaN\n$x->digit($n);           # the nth digit, counting from the right\n$x->digit(-$n);          # the nth digit, counting from the left\n$x->length();            # return number of digits in number\n($xl,$f) = $x->length(); # length of number and length of fraction\n# part, latter is always 0 digits long\n# for Math::BigInt objects\n$x->mantissa();          # return (signed) mantissa as BigInt\n$x->exponent();          # return exponent as BigInt\n$x->parts();             # return (mantissa,exponent) as BigInt\n$x->sparts();            # mantissa and exponent (as integers)\n$x->nparts();            # mantissa and exponent (normalised)\n$x->eparts();            # mantissa and exponent (engineering notation)\n$x->dparts();            # integer and fraction part\n$x->fparts();            # numerator and denominator\n$x->numerator();         # numerator\n$x->denominator();       # denominator\n# Conversion methods (do not modify the invocand)\n$x->bstr();         # decimal notation, possibly zero padded\n$x->bsstr();        # string in scientific notation with integers\n$x->bnstr();        # string in normalized notation\n$x->bestr();        # string in engineering notation\n$x->bdstr();        # string in decimal notation\n$x->ashex();       # as signed hexadecimal string with prefixed 0x\n$x->asbin();       # as signed binary string with prefixed 0b\n$x->asoct();       # as signed octal string with prefixed 0\n$x->toieee754($format); # to bytes encoded according to IEEE 754-2008\n# Other conversion methods\n$x->numify();           # return as scalar (might overflow or underflow)",
    "sections": {
        "NAME": {
            "content": "Math::BigFloat - Arbitrary size floating point math package\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Math::BigFloat;\n\n# Configuration methods (may be used as class methods and instance methods)\n\nMath::BigFloat->accuracy();     # get class accuracy\nMath::BigFloat->accuracy($n);   # set class accuracy\nMath::BigFloat->precision();    # get class precision\nMath::BigFloat->precision($n);  # set class precision\nMath::BigFloat->roundmode();   # get class rounding mode\nMath::BigFloat->roundmode($m); # set global round mode, must be one of\n# 'even', 'odd', '+inf', '-inf', 'zero',\n# 'trunc', or 'common'\nMath::BigFloat->config(\"lib\");  # name of backend math library\n\n# Constructor methods (when the class methods below are used as instance\n# methods, the value is assigned the invocand)\n\n$x = Math::BigFloat->new($str);               # defaults to 0\n$x = Math::BigFloat->new('0x123');            # from hexadecimal\n$x = Math::BigFloat->new('0o377');            # from octal\n$x = Math::BigFloat->new('0b101');            # from binary\n$x = Math::BigFloat->fromhex('0xc.afep+3');  # from hex\n$x = Math::BigFloat->fromhex('cafe');        # ditto\n$x = Math::BigFloat->fromoct('1.3267p-4');   # from octal\n$x = Math::BigFloat->fromoct('01.3267p-4');  # ditto\n$x = Math::BigFloat->fromoct('0o1.3267p-4'); # ditto\n$x = Math::BigFloat->fromoct('0377');        # ditto\n$x = Math::BigFloat->frombin('0b1.1001p-4'); # from binary\n$x = Math::BigFloat->frombin('0101');        # ditto\n$x = Math::BigFloat->fromieee754($b, \"binary64\");  # from IEEE-754 bytes\n$x = Math::BigFloat->bzero();                 # create a +0\n$x = Math::BigFloat->bone();                  # create a +1\n$x = Math::BigFloat->bone('-');               # create a -1\n$x = Math::BigFloat->binf();                  # create a +inf\n$x = Math::BigFloat->binf('-');               # create a -inf\n$x = Math::BigFloat->bnan();                  # create a Not-A-Number\n$x = Math::BigFloat->bpi();                   # returns pi\n\n$y = $x->copy();        # make a copy (unlike $y = $x)\n$y = $x->asint();      # return as BigInt\n\n# Boolean methods (these don't modify the invocand)\n\n$x->iszero();          # if $x is 0\n$x->isone();           # if $x is +1\n$x->isone(\"+\");        # ditto\n$x->isone(\"-\");        # if $x is -1\n$x->isinf();           # if $x is +inf or -inf\n$x->isinf(\"+\");        # if $x is +inf\n$x->isinf(\"-\");        # if $x is -inf\n$x->isnan();           # if $x is NaN\n\n$x->ispositive();      # if $x > 0\n$x->ispos();           # ditto\n$x->isnegative();      # if $x < 0\n$x->isneg();           # ditto\n\n$x->isodd();           # if $x is odd\n$x->iseven();          # if $x is even\n$x->isint();           # if $x is an integer\n\n# Comparison methods\n\n$x->bcmp($y);           # compare numbers (undef, < 0, == 0, > 0)\n$x->bacmp($y);          # compare absolutely (undef, < 0, == 0, > 0)\n$x->beq($y);            # true if and only if $x == $y\n$x->bne($y);            # true if and only if $x != $y\n$x->blt($y);            # true if and only if $x < $y\n$x->ble($y);            # true if and only if $x <= $y\n$x->bgt($y);            # true if and only if $x > $y\n$x->bge($y);            # true if and only if $x >= $y\n\n# Arithmetic methods\n\n$x->bneg();             # negation\n$x->babs();             # absolute value\n$x->bsgn();             # sign function (-1, 0, 1, or NaN)\n$x->bnorm();            # normalize (no-op)\n$x->binc();             # increment $x by 1\n$x->bdec();             # decrement $x by 1\n$x->badd($y);           # addition (add $y to $x)\n$x->bsub($y);           # subtraction (subtract $y from $x)\n$x->bmul($y);           # multiplication (multiply $x by $y)\n$x->bmuladd($y,$z);     # $x = $x * $y + $z\n$x->bdiv($y);           # division (floored), set $x to quotient\n# return (quo,rem) or quo if scalar\n$x->btdiv($y);          # division (truncated), set $x to quotient\n# return (quo,rem) or quo if scalar\n$x->bmod($y);           # modulus (x % y)\n$x->btmod($y);          # modulus (truncated)\n$x->bmodinv($mod);      # modular multiplicative inverse\n$x->bmodpow($y,$mod);   # modular exponentiation (($x  $y) % $mod)\n$x->bpow($y);           # power of arguments (x  y)\n$x->blog();             # logarithm of $x to base e (Euler's number)\n$x->blog($base);        # logarithm of $x to base $base (e.g., base 2)\n$x->bexp();             # calculate e  $x where e is Euler's number\n$x->bnok($y);           # x over y (binomial coefficient n over k)\n$x->bsin();             # sine\n$x->bcos();             # cosine\n$x->batan();            # inverse tangent\n$x->batan2($y);         # two-argument inverse tangent\n$x->bsqrt();            # calculate square root\n$x->broot($y);          # $y'th root of $x (e.g. $y == 3 => cubic root)\n$x->bfac();             # factorial of $x (1*2*3*4*..$x)\n\n$x->blsft($n);          # left shift $n places in base 2\n$x->blsft($n,$b);       # left shift $n places in base $b\n# returns (quo,rem) or quo (scalar context)\n$x->brsft($n);          # right shift $n places in base 2\n$x->brsft($n,$b);       # right shift $n places in base $b\n# returns (quo,rem) or quo (scalar context)\n\n# Bitwise methods\n\n$x->band($y);           # bitwise and\n$x->bior($y);           # bitwise inclusive or\n$x->bxor($y);           # bitwise exclusive or\n$x->bnot();             # bitwise not (two's complement)\n\n# Rounding methods\n$x->round($A,$P,$mode); # round to accuracy or precision using\n# rounding mode $mode\n$x->bround($n);         # accuracy: preserve $n digits\n$x->bfround($n);        # $n > 0: round to $nth digit left of dec. point\n# $n < 0: round to $nth digit right of dec. point\n$x->bfloor();           # round towards minus infinity\n$x->bceil();            # round towards plus infinity\n$x->bint();             # round towards zero\n\n# Other mathematical methods\n\n$x->bgcd($y);            # greatest common divisor\n$x->blcm($y);            # least common multiple\n\n# Object property methods (do not modify the invocand)\n\n$x->sign();              # the sign, either +, - or NaN\n$x->digit($n);           # the nth digit, counting from the right\n$x->digit(-$n);          # the nth digit, counting from the left\n$x->length();            # return number of digits in number\n($xl,$f) = $x->length(); # length of number and length of fraction\n# part, latter is always 0 digits long\n# for Math::BigInt objects\n$x->mantissa();          # return (signed) mantissa as BigInt\n$x->exponent();          # return exponent as BigInt\n$x->parts();             # return (mantissa,exponent) as BigInt\n$x->sparts();            # mantissa and exponent (as integers)\n$x->nparts();            # mantissa and exponent (normalised)\n$x->eparts();            # mantissa and exponent (engineering notation)\n$x->dparts();            # integer and fraction part\n$x->fparts();            # numerator and denominator\n$x->numerator();         # numerator\n$x->denominator();       # denominator\n\n# Conversion methods (do not modify the invocand)\n\n$x->bstr();         # decimal notation, possibly zero padded\n$x->bsstr();        # string in scientific notation with integers\n$x->bnstr();        # string in normalized notation\n$x->bestr();        # string in engineering notation\n$x->bdstr();        # string in decimal notation\n$x->ashex();       # as signed hexadecimal string with prefixed 0x\n$x->asbin();       # as signed binary string with prefixed 0b\n$x->asoct();       # as signed octal string with prefixed 0\n$x->toieee754($format); # to bytes encoded according to IEEE 754-2008\n\n# Other conversion methods\n\n$x->numify();           # return as scalar (might overflow or underflow)\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Math::BigFloat provides support for arbitrary precision floating point. Overloading is also\nprovided for Perl operators.\n\nAll operators (including basic math operations) are overloaded if you declare your big floating\npoint numbers as\n\n$x = Math::BigFloat -> new('123.456789123456789E-2');\n\nOperations with overloaded operators preserve the arguments, which is exactly what you expect.\n",
            "subsections": [
                {
                    "name": "Input",
                    "content": "Input values to these routines may be any scalar number or string that looks like a number.\nAnything that is accepted by Perl as a literal numeric constant should be accepted by this\nmodule.\n\n*   Leading and trailing whitespace is ignored.\n\n*   Leading zeros are ignored, except for floating point numbers with a binary exponent, in\nwhich case the number is interpreted as an octal floating point number. For example,\n\"01.4p+0\" gives 1.5, \"00.4p+0\" gives 0.5, but \"0.4p+0\" gives a NaN. And while \"0377\" gives\n255, \"0377p0\" gives 255.\n\n*   If the string has a \"0x\" or \"0X\" prefix, it is interpreted as a hexadecimal number.\n\n*   If the string has a \"0o\" or \"0O\" prefix, it is interpreted as an octal number. A floating\npoint literal with a \"0\" prefix is also interpreted as an octal number.\n\n*   If the string has a \"0b\" or \"0B\" prefix, it is interpreted as a binary number.\n\n*   Underline characters are allowed in the same way as they are allowed in literal numerical\nconstants.\n\n*   If the string can not be interpreted, NaN is returned.\n\n*   For hexadecimal, octal, and binary floating point numbers, the exponent must be separated\nfrom the significand (mantissa) by the letter \"p\" or \"P\", not \"e\" or \"E\" as with decimal\nnumbers.\n\nSome examples of valid string input\n\nInput string                Resulting value\n\n123                         123\n1.23e2                      123\n12300e-2                    123\n\n67538754                  67538754\n-456.789e+010         -4567890000000\n\n0x13a                       314\n0x13ap0                     314\n0x1.3ap+8                   314\n0x0.00013ap+24              314\n0x13a000p-12                314\n\n0o472                       314\n0o1.164p+8                  314\n0o0.0001164p+20             314\n0o1164000p-10               314\n\n0472                        472     Note!\n01.164p+8                   314\n00.0001164p+20              314\n01164000p-10                314\n\n0b100111010                 314\n0b1.0011101p+8              314\n0b0.00010011101p+12         314\n0b100111010000p-3           314\n\n0x1.921fb5p+1               3.14159262180328369140625e+0\n0o1.2677025p1               2.71828174591064453125\n01.2677025p1                2.71828174591064453125\n0b1.1001p-4                 9.765625e-2\n"
                },
                {
                    "name": "Output",
                    "content": "Output values are usually Math::BigFloat objects.\n\nBoolean operators \"iszero()\", \"isone()\", \"isinf()\", etc. return true or false.\n\nComparison operators \"bcmp()\" and \"bacmp()\") return -1, 0, 1, or undef.\n"
                }
            ]
        },
        "METHODS": {
            "content": "Math::BigFloat supports all methods that Math::BigInt supports, except it calculates non-integer\nresults when possible. Please see Math::BigInt for a full description of each method. Below are\njust the most important differences:\n",
            "subsections": [
                {
                    "name": "Configuration methods",
                    "content": ""
                },
                {
                    "name": "accuracy",
                    "content": "$x->accuracy(5);           # local for $x\nCLASS->accuracy(5);        # global for all members of CLASS\n# Note: This also applies to new()!\n\n$A = $x->accuracy();       # read out accuracy that affects $x\n$A = CLASS->accuracy();    # read out global accuracy\n\nSet or get the global or local accuracy, aka how many significant digits the results have.\nIf you set a global accuracy, then this also applies to new()!\n\nWarning! The accuracy *sticks*, e.g. once you created a number under the influence of\n\"CLASS->accuracy($A)\", all results from math operations with that number will also be\nrounded.\n\nIn most cases, you should probably round the results explicitly using one of \"round()\" in\nMath::BigInt, \"bround()\" in Math::BigInt or \"bfround()\" in Math::BigInt or by passing the\ndesired accuracy to the math operation as additional parameter:\n\nmy $x = Math::BigInt->new(30000);\nmy $y = Math::BigInt->new(7);\nprint scalar $x->copy()->bdiv($y, 2);           # print 4300\nprint scalar $x->copy()->bdiv($y)->bround(2);   # print 4300\n"
                },
                {
                    "name": "precision",
                    "content": "$x->precision(-2);        # local for $x, round at the second\n# digit right of the dot\n$x->precision(2);         # ditto, round at the second digit\n# left of the dot\n\nCLASS->precision(5);      # Global for all members of CLASS\n# This also applies to new()!\nCLASS->precision(-5);     # ditto\n\n$P = CLASS->precision();  # read out global precision\n$P = $x->precision();     # read out precision that affects $x\n\nNote: You probably want to use \"accuracy()\" instead. With \"accuracy()\" you set the number of\ndigits each result should have, with \"precision()\" you set the place where to round!\n"
                },
                {
                    "name": "Constructor methods",
                    "content": ""
                },
                {
                    "name": "from_hex",
                    "content": "$x -> fromhex(\"0x1.921fb54442d18p+1\");\n$x = Math::BigFloat -> fromhex(\"0x1.921fb54442d18p+1\");\n\nInterpret input as a hexadecimal string.A prefix (\"0x\", \"x\", ignoring case) is optional. A\nsingle underscore character (\"\") may be placed between any two digits. If the input is\ninvalid, a NaN is returned. The exponent is in base 2 using decimal digits.\n\nIf called as an instance method, the value is assigned to the invocand.\n"
                },
                {
                    "name": "from_oct",
                    "content": "$x -> fromoct(\"1.3267p-4\");\n$x = Math::BigFloat -> fromoct(\"1.3267p-4\");\n\nInterpret input as an octal string. A single underscore character (\"\") may be placed\nbetween any two digits. If the input is invalid, a NaN is returned. The exponent is in base\n2 using decimal digits.\n\nIf called as an instance method, the value is assigned to the invocand.\n"
                },
                {
                    "name": "from_bin",
                    "content": "$x -> frombin(\"0b1.1001p-4\");\n$x = Math::BigFloat -> frombin(\"0b1.1001p-4\");\n\nInterpret input as a hexadecimal string. A prefix (\"0b\" or \"b\", ignoring case) is optional.\nA single underscore character (\"\") may be placed between any two digits. If the input is\ninvalid, a NaN is returned. The exponent is in base 2 using decimal digits.\n\nIf called as an instance method, the value is assigned to the invocand.\n"
                },
                {
                    "name": "from_ieee754",
                    "content": "Interpret the input as a value encoded as described in IEEE754-2008. The input can be given\nas a byte string, hex string or binary string. The input is assumed to be in big-endian\nbyte-order.\n\n# both $dbl and $mbf are 3.141592...\n$bytes = \"\\x40\\x09\\x21\\xfb\\x54\\x44\\x2d\\x18\";\n$dbl = unpack \"d>\", $bytes;\n$mbf = Math::BigFloat -> fromieee754($bytes, \"binary64\");\n"
                },
                {
                    "name": "bpi",
                    "content": "print Math::BigFloat->bpi(100), \"\\n\";\n\nCalculate PI to N digits (including the 3 before the dot). The result is rounded according\nto the current rounding mode, which defaults to \"even\".\n\nThis method was added in v1.87 of Math::BigInt (June 2007).\n"
                },
                {
                    "name": "Arithmetic methods",
                    "content": ""
                },
                {
                    "name": "bmuladd",
                    "content": "$x->bmuladd($y,$z);\n\nMultiply $x by $y, and then add $z to the result.\n\nThis method was added in v1.87 of Math::BigInt (June 2007).\n"
                },
                {
                    "name": "bdiv",
                    "content": "$q = $x->bdiv($y);\n($q, $r) = $x->bdiv($y);\n\nIn scalar context, divides $x by $y and returns the result to the given or default\naccuracy/precision. In list context, does floored division (F-division), returning an\ninteger $q and a remainder $r so that $x = $q * $y + $r. The remainer (modulo) is equal to\nwhat is returned by \"$x->bmod($y)\".\n"
                },
                {
                    "name": "bmod",
                    "content": "$x->bmod($y);\n\nReturns $x modulo $y. When $x is finite, and $y is finite and non-zero, the result is\nidentical to the remainder after floored division (F-division). If, in addition, both $x and\n$y are integers, the result is identical to the result from Perl's % operator.\n"
                },
                {
                    "name": "bexp",
                    "content": "$x->bexp($accuracy);            # calculate e  X\n\nCalculates the expression \"e  $x\" where \"e\" is Euler's number.\n\nThis method was added in v1.82 of Math::BigInt (April 2007).\n"
                },
                {
                    "name": "bnok",
                    "content": "$x->bnok($y);   # x over y (binomial coefficient n over k)\n\nCalculates the binomial coefficient n over k, also called the \"choose\" function. The result\nis equivalent to:\n\n( n )      n!\n| - |  = -------\n( k )    k!(n-k)!\n\nThis method was added in v1.84 of Math::BigInt (April 2007).\n"
                },
                {
                    "name": "bsin",
                    "content": "my $x = Math::BigFloat->new(1);\nprint $x->bsin(100), \"\\n\";\n\nCalculate the sinus of $x, modifying $x in place.\n\nThis method was added in v1.87 of Math::BigInt (June 2007).\n"
                },
                {
                    "name": "bcos",
                    "content": "my $x = Math::BigFloat->new(1);\nprint $x->bcos(100), \"\\n\";\n\nCalculate the cosinus of $x, modifying $x in place.\n\nThis method was added in v1.87 of Math::BigInt (June 2007).\n"
                },
                {
                    "name": "batan",
                    "content": "my $x = Math::BigFloat->new(1);\nprint $x->batan(100), \"\\n\";\n\nCalculate the arcus tanges of $x, modifying $x in place. See also \"batan2()\".\n\nThis method was added in v1.87 of Math::BigInt (June 2007).\n"
                },
                {
                    "name": "batan2",
                    "content": "my $y = Math::BigFloat->new(2);\nmy $x = Math::BigFloat->new(3);\nprint $y->batan2($x), \"\\n\";\n\nCalculate the arcus tanges of $y divided by $x, modifying $y in place. See also \"batan()\".\n\nThis method was added in v1.87 of Math::BigInt (June 2007).\n"
                },
                {
                    "name": "as_float",
                    "content": "This method is called when Math::BigFloat encounters an object it doesn't know how to\nhandle. For instance, assume $x is a Math::BigFloat, or subclass thereof, and $y is defined,\nbut not a Math::BigFloat, or subclass thereof. If you do\n\n$x -> badd($y);\n\n$y needs to be converted into an object that $x can deal with. This is done by first\nchecking if $y is something that $x might be upgraded to. If that is the case, no further\nattempts are made. The next is to see if $y supports the method \"asfloat()\". The method\n\"asfloat()\" is expected to return either an object that has the same class as $x, a\nsubclass thereof, or a string that \"ref($x)->new()\" can parse to create an object.\n\nIn Math::BigFloat, \"asfloat()\" has the same effect as \"copy()\".\n"
                },
                {
                    "name": "to_ieee754",
                    "content": "Encodes the invocand as a byte string in the given format as specified in IEEE 754-2008.\nNote that the encoded value is the nearest possible representation of the value. This value\nmight not be exactly the same as the value in the invocand.\n\n# $x = 3.1415926535897932385\n$x = Math::BigFloat -> bpi(30);\n\n$b = $x -> toieee754(\"binary64\");  # encode as 8 bytes\n$h = unpack \"H*\", $b;               # \"400921fb54442d18\"\n\n# 3.141592653589793115997963...\n$y = Math::BigFloat -> fromieee754($h, \"binary64\");\n\nAll binary formats in IEEE 754-2008 are accepted. For convenience, som aliases are\nrecognized: \"half\" for \"binary16\", \"single\" for \"binary32\", \"double\" for \"binary64\",\n\"quadruple\" for \"binary128\", \"octuple\" for \"binary256\", and \"sexdecuple\" for \"binary512\".\n\nSee also <https://en.wikipedia.org/wiki/IEEE754>.\n\nACCURACY AND PRECISION\nSee also: Rounding.\n\nMath::BigFloat supports both precision (rounding to a certain place before or after the dot) and\naccuracy (rounding to a certain number of digits). For a full documentation, examples and tips\non these topics please see the large section about rounding in Math::BigInt.\n\nSince things like sqrt(2) or \"1 / 3\" must presented with a limited accuracy lest a operation\nconsumes all resources, each operation produces no more than the requested number of digits.\n\nIf there is no global precision or accuracy set, and the operation in question was not called\nwith a requested precision or accuracy, and the input $x has no accuracy or precision set, then\na fallback parameter will be used. For historical reasons, it is called \"divscale\" and can be\naccessed via:\n\n$d = Math::BigFloat->divscale();       # query\nMath::BigFloat->divscale($n);          # set to $n digits\n\nThe default value for \"divscale\" is 40.\n\nIn case the result of one operation has more digits than specified, it is rounded. The rounding\nmode taken is either the default mode, or the one supplied to the operation after the *scale*:\n\n$x = Math::BigFloat->new(2);\nMath::BigFloat->accuracy(5);              # 5 digits max\n$y = $x->copy()->bdiv(3);                 # gives 0.66667\n$y = $x->copy()->bdiv(3,6);               # gives 0.666667\n$y = $x->copy()->bdiv(3,6,undef,'odd');   # gives 0.666667\nMath::BigFloat->roundmode('zero');\n$y = $x->copy()->bdiv(3,6);               # will also give 0.666667\n\nNote that \"Math::BigFloat->accuracy()\" and \"Math::BigFloat->precision()\" set the global\nvariables, and thus any newly created number will be subject to the global rounding immediately.\nThis means that in the examples above, the 3 as argument to \"bdiv()\" will also get an accuracy\nof 5.\n\nIt is less confusing to either calculate the result fully, and afterwards round it explicitly,\nor use the additional parameters to the math functions like so:\n\nuse Math::BigFloat;\n$x = Math::BigFloat->new(2);\n$y = $x->copy()->bdiv(3);\nprint $y->bround(5),\"\\n\";               # gives 0.66667\n\nor\n\nuse Math::BigFloat;\n$x = Math::BigFloat->new(2);\n$y = $x->copy()->bdiv(3,5);             # gives 0.66667\nprint \"$y\\n\";\n"
                },
                {
                    "name": "Rounding",
                    "content": "bfround ( +$scale )\nRounds to the $scale'th place left from the '.', counting from the dot. The first digit is\nnumbered 1.\n\nbfround ( -$scale )\nRounds to the $scale'th place right from the '.', counting from the dot.\n\nbfround ( 0 )\nRounds to an integer.\n\nbround ( +$scale )\nPreserves accuracy to $scale digits from the left (aka significant digits) and pads the rest\nwith zeros. If the number is between 1 and -1, the significant digits count from the first\nnon-zero after the '.'\n\nbround ( -$scale ) and bround ( 0 )\nThese are effectively no-ops.\n\nAll rounding functions take as a second parameter a rounding mode from one of the following:\n'even', 'odd', '+inf', '-inf', 'zero', 'trunc' or 'common'.\n\nThe default rounding mode is 'even'. By using \"Math::BigFloat->roundmode($roundmode);\" you can\nget and set the default mode for subsequent rounding. The usage of\n\"$Math::BigFloat::$roundmode\" is no longer supported. The second parameter to the round\nfunctions then overrides the default temporarily.\n\nThe \"asnumber()\" function returns a BigInt from a Math::BigFloat. It uses 'trunc' as rounding\nmode to make it equivalent to:\n\n$x = 2.5;\n$y = int($x) + 2;\n\nYou can override this by passing the desired rounding mode as parameter to \"asnumber()\":\n\n$x = Math::BigFloat->new(2.5);\n$y = $x->asnumber('odd');      # $y = 3\n"
                }
            ]
        },
        "NUMERIC LITERALS": {
            "content": "After \"use Math::BigFloat ':constant'\" all numeric literals in the given scope are converted to\n\"Math::BigFloat\" objects. This conversion happens at compile time.\n\nFor example,\n\nperl -MMath::BigFloat=:constant -le 'print 2e-150'\n\nprints the exact value of 2e-150. Note that without conversion of constants the expression\n2e-150 is calculated using Perl scalars, which leads to an inaccuracte result.\n\nNote that strings are not affected, so that\n\nuse Math::BigFloat qw/:constant/;\n\n$y = \"1234567890123456789012345678901234567890\"\n+ \"123456789123456789\";\n\ndoes not give you what you expect. You need an explicit Math::BigFloat->new() around at least\none of the operands. You should also quote large constants to prevent loss of precision:\n\nuse Math::BigFloat;\n\n$x = Math::BigFloat->new(\"1234567889123456789123456789123456789\");\n\nWithout the quotes Perl converts the large number to a floating point constant at compile time,\nand then converts the result to a Math::BigFloat object at runtime, which results in an\ninaccurate result.\n",
            "subsections": [
                {
                    "name": "Hexadecimal, octal, and binary floating point literals",
                    "content": "Perl (and this module) accepts hexadecimal, octal, and binary floating point literals, but use\nthem with care with Perl versions before v5.32.0, because some versions of Perl silently give\nthe wrong result. Below are some examples of different ways to write the number decimal 314.\n\nHexadecimal floating point literals:\n\n0x1.3ap+8         0X1.3AP+8\n0x1.3ap8          0X1.3AP8\n0x13a0p-4         0X13A0P-4\n\nOctal floating point literals (with \"0\" prefix):\n\n01.164p+8         01.164P+8\n01.164p8          01.164P8\n011640p-4         011640P-4\n\nOctal floating point literals (with \"0o\" prefix) (requires v5.34.0):\n\n0o1.164p+8        0O1.164P+8\n0o1.164p8         0O1.164P8\n0o11640p-4        0O11640P-4\n\nBinary floating point literals:\n\n0b1.0011101p+8    0B1.0011101P+8\n0b1.0011101p8     0B1.0011101P8\n0b10011101000p-2  0B10011101000P-2\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 Math::BigFloat lib => \"Calc\";\n\nYou can change this by using:\n\nuse Math::BigFloat lib => \"GMP\";\n\nNote: General purpose packages should not be explicit about the library to use; let the script\nauthor decide which is best.\n\nNote: The keyword 'lib' will warn when the requested library could not be loaded. To suppress\nthe warning use 'try' instead:\n\nuse Math::BigFloat try => \"GMP\";\n\nIf your script works with huge numbers and Calc is too slow for them, you can also for the\nloading of one of these libraries and if none of them can be used, the code will die:\n\nuse Math::BigFloat only => \"GMP,Pari\";\n\nThe following would first try to find Math::BigInt::Foo, then Math::BigInt::Bar, and when this\nalso fails, revert to Math::BigInt::Calc:\n\nuse Math::BigFloat lib => \"Foo,Math::BigInt::Bar\";\n\nSee the respective low-level library documentation for further details.\n\nSee Math::BigInt for more details about using a different low-level library.\n"
                },
                {
                    "name": "Using Math::BigInt::Lite",
                    "content": "For backwards compatibility reasons it is still possible to request a different storage class\nfor use with Math::BigFloat:\n\nuse Math::BigFloat with => 'Math::BigInt::Lite';\n\nHowever, this request is ignored, as the current code now uses the low-level math library for\ndirectly storing the number parts.\n"
                }
            ]
        },
        "EXPORTS": {
            "content": "\"Math::BigFloat\" exports nothing by default, but can export the \"bpi()\" method:\n\nuse Math::BigFloat qw/bpi/;\n\nprint bpi(10), \"\\n\";\n",
            "subsections": []
        },
        "CAVEATS": {
            "content": "Do not try to be clever to insert some operations in between switching libraries:\n\nrequire Math::BigFloat;\nmy $matter = Math::BigFloat->bone() + 4;    # load BigInt and Calc\nMath::BigFloat->import( lib => 'Pari' );    # load Pari, too\nmy $antimatter = Math::BigFloat->bone()+4; # now use Pari\n\nThis will create objects with numbers stored in two different backend libraries, and VERY BAD\nTHINGS will happen when you use these together:\n\nmy $flashandbang = $matter + $antimatter;    # Don't do this!\n\nstringify, bstr()\nBoth stringify and bstr() now drop the leading '+'. The old code would return '+1.23', the\nnew returns '1.23'. See the documentation in Math::BigInt for reasoning and details.\n",
            "subsections": [
                {
                    "name": "brsft",
                    "content": "The following will probably not print what you expect:\n\nmy $c = Math::BigFloat->new('3.14159');\nprint $c->brsft(3,10),\"\\n\";     # prints 0.00314153.1415\n\nIt prints both quotient and remainder, since print calls \"brsft()\" in list context. Also,\n\"$c->brsft()\" will modify $c, so be careful. You probably want to use\n\nprint scalar $c->copy()->brsft(3,10),\"\\n\";\n# or if you really want to modify $c\nprint scalar $c->brsft(3,10),\"\\n\";\n\ninstead.\n\nModifying and =\nBeware of:\n\n$x = Math::BigFloat->new(5);\n$y = $x;\n\nIt will not do what you think, e.g. making a copy of $x. Instead it just makes a second\nreference to the same object and stores it in $y. Thus anything that modifies $x will modify\n$y (except overloaded math operators), and vice versa. See Math::BigInt for details and how\nto avoid that.\n"
                },
                {
                    "name": "precision",
                    "content": "A common pitfall is to use \"precision()\" when you want to round a result to a certain number\nof digits:\n\nuse Math::BigFloat;\n\nMath::BigFloat->precision(4);           # does not do what you\n# think it does\nmy $x = Math::BigFloat->new(12345);     # rounds $x to \"12000\"!\nprint \"$x\\n\";                           # print \"12000\"\nmy $y = Math::BigFloat->new(3);         # rounds $y to \"0\"!\nprint \"$y\\n\";                           # print \"0\"\n$z = $x / $y;                           # 12000 / 0 => NaN!\nprint \"$z\\n\";\nprint $z->precision(),\"\\n\";             # 4\n\nReplacing \"precision()\" with \"accuracy()\" is probably not what you want, either:\n\nuse Math::BigFloat;\n\nMath::BigFloat->accuracy(4);          # enables global rounding:\nmy $x = Math::BigFloat->new(123456);  # rounded immediately\n#   to \"12350\"\nprint \"$x\\n\";                         # print \"123500\"\nmy $y = Math::BigFloat->new(3);       # rounded to \"3\nprint \"$y\\n\";                         # print \"3\"\nprint $z = $x->copy()->bdiv($y),\"\\n\"; # 41170\nprint $z->accuracy(),\"\\n\";            # 4\n\nWhat you want to use instead is:\n\nuse Math::BigFloat;\n\nmy $x = Math::BigFloat->new(123456);    # no rounding\nprint \"$x\\n\";                           # print \"123456\"\nmy $y = Math::BigFloat->new(3);         # no rounding\nprint \"$y\\n\";                           # print \"3\"\nprint $z = $x->copy()->bdiv($y,4),\"\\n\"; # 41150\nprint $z->accuracy(),\"\\n\";              # undef\n\nIn addition to computing what you expected, the last example also does not \"taint\" the\nresult with an accuracy or precision setting, which would influence any further operation.\n"
                }
            ]
        },
        "BUGS": {
            "content": "Please report any bugs or feature requests to \"bug-math-bigint at rt.cpan.org\", or through the\nweb interface at <https://rt.cpan.org/Ticket/Create.html?Queue=Math-BigInt> (requires login). We\nwill be notified, and then you'll automatically be notified of progress on your bug as I make\nchanges.\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "You can find documentation for this module with the perldoc command.\n\nperldoc Math::BigFloat\n\nYou can also look for information at:\n\n*   GitHub\n\n<https://github.com/pjacklam/p5-Math-BigInt>\n\n*   RT: CPAN's request tracker\n\n<https://rt.cpan.org/Dist/Display.html?Name=Math-BigInt>\n\n*   MetaCPAN\n\n<https://metacpan.org/release/Math-BigInt>\n\n*   CPAN Testers Matrix\n\n<http://matrix.cpantesters.org/?dist=Math-BigInt>\n\n*   CPAN Ratings\n\n<https://cpanratings.perl.org/dist/Math-BigInt>\n\n*   The Bignum mailing list\n\n*   Post to mailing list\n\n\"bignum at lists.scsys.co.uk\"\n\n*   View mailing list\n\n<http://lists.scsys.co.uk/pipermail/bignum/>\n\n*   Subscribe/Unsubscribe\n\n<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/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": "Math::BigInt and Math::BigInt as well as the backends Math::BigInt::FastCalc, Math::BigInt::GMP,\nand Math::BigInt::Pari.\n\nThe pragmas bignum, bigint and bigrat.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Mark Biggar, overloaded interface by Ilya Zakharevich, 1996-2001.\n\n*   Completely rewritten by Tels <http://bloodgate.com> in 2001-2008.\n\n*   Florian Ragwitz <flora@cpan.org>, 2010.\n\n*   Peter John Acklam <pjacklam@gmail.com>, 2011-.\n",
            "subsections": []
        }
    },
    "summary": "Math::BigFloat - Arbitrary size floating point math package",
    "flags": [],
    "examples": [],
    "see_also": []
}