CINXE.COM

bigint - transparent big integer support for Perl - metacpan.org

<!DOCTYPE html> <html lang="en-US"> <head> <title>bigint - transparent big integer support for Perl - metacpan.org</title> <link rel="preload" as="fetch" href="/account/login_status" crossorigin="anonymous" /> <link href="/assets/style-XFEQ536G.css" rel="stylesheet" type="text/css"> <script src="/assets/main-WXBSEDQJ.js" type="module"></script> <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of bignum - MetaCPAN" href="/dist/bignum/releases.rss" /> <link rel="canonical" href="https://metacpan.org/pod/bigint" /> <meta name="description" content="transparent big integer support for Perl" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5"> <link rel="shortcut icon" href="/static/icons/favicon.ico"> <link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-touch-icon.png"> <link rel="search" href="/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN"> <script async src="https://perl-ads.perlhacks.com/perl-ads.js"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=G-E82Q2V8LVD"></script> <meta property="og:site_name" content="MetaCPAN" /> <meta name="twitter:site" content="@metacpan" /> <meta property="og:type" content="article" /> <meta name="twitter:card" content="summary" /> <meta property="og:url" content="https://metacpan.org/pod/bigint" /> <meta property="og:title" content="bigint" /> <meta property="og:description" content="transparent big integer support for Perl" /> <meta property="og:image" content="https://metacpan.org/static/images/dots.png" /> </head> <body> <nav class="navbar navbar-default" role="navigation"> <div class="header-logo-large hidden-xs"> <a href="/" tabindex="0"> <svg class="logo" aria-label="MetaCPAN"> <use class="logo" href="/static/images/metacpan-logo.svg#logo" /> </svg> </a> </div> <div class="header-logo-icon visible-xs"> <a href="/"> <svg class="logo" aria-label="MetaCPAN"> <use class="logo" href="/static/images/metacpan-logo.svg#dots" /> </svg> </a> </div> <ul class="nav navbar-nav menu-items hidden-xs hidden-sm"> <li><a href="/about">About</a></li> <li><a href="/about/sponsors">Sponsor</a></li> <li><a href="https://grep.metacpan.org/">grep::cpan</a></li> <li><a href="/recent">Recent</a></li> <li><a href="/about/faq">FAQ</a></li> <li><a href="/tools">Tools</a></li> <li><a href="https://fastapi.metacpan.org/">API</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <button type="button" class="searchbar-btn visible-xs visible-sm"> <i class="fa fa-search button-fa-icon"></i> </button> <form action="/search" class="searchbar-form visible-md visible-lg search-form form-horizontal"> <input type="hidden" name="size" id="metacpan_search-size" value="20"> <div class="form-group"> <div class="search-group"> <i class="fa fa-search"></i> <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value=""> </div> </div> </form> <li class="icon-slidepanel visible-xs visible-sm"> <button data-toggle="slidepanel" data-target=".slidepanel"> <span class="button-fa-icon"> <i class="fa fa-bars slidepanel-open"></i> <i class="fa fa-times slidepanel-close"></i> </span> </button> </li> <li class="dropdown login-dropdown show-logged-in"> <button type="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i> <i class="fas fa-chevron-down"></i> </button> <ul class="dropdown-menu"> <li><a href="/account/identities">Identities</a></li> <li><a href="/account/profile">Profile</a></li> <li><a href="/account/favorite/list">Favorites</a></li> <li> <a href="#" type="button" class="logout-button"> Logout </a> </li> </ul> </li> <li class="dropdown login-dropdown show-logged-out"> <button type="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user button-fa-icon avatar-placeholder" aria-hidden="true"></i> <i class="fas fa-chevron-down"></i> </button> <ul class="dropdown-menu"> <li> <a href="/login/github"> <i class="fab fa-github fa-fw"></i> GitHub </a> </li> <li> <a href="/login/twitter"> <i class="fab fa-twitter fa-fw"></i> Twitter </a> </li> <li> <a href="/login/google"> <i class="fab fa-google fa-fw"></i> Google </a> </li> </ul> </li> <li class="dropdown login-dropdown hide-logged-in hide-logged-out"> <button> <i class="fa fa-user button-fa-icon" aria-hidden="true"></i> </button> </li> </ul> </nav> <div class="page-content "> <div id="perl-ad-target" class="top-notify-banner perl-ad-target"> </div> <nav class="sidebar"> <div class="slidepanel"> <ul class="nav-list "> <li class="nav-header no-margin-top"> <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of bignum was released."> <span class="relatize">30 Dec 2023 13:48:09 UTC</span> </div> </li> <li> Distribution: <a href="/dist/bignum">bignum</a> </li> <li> Module version: 0.67 </li> <li> <a data-keyboard-shortcut="g s" href="/dist/bignum/source/lib/bigint.pm">Source</a> (<a href="/dist/bignum/source/lib/bigint.pm?raw=1">raw</a>) </li> <li> <a data-keyboard-shortcut="g b" href="/dist/bignum/source/lib">Browse</a> (<a href="/dist/bignum/source/lib?raw=1">raw</a>) </li> <li> <a data-keyboard-shortcut="g c" href="/dist/bignum/changes">Changes</a> </li> <li> <a class="nopopup" href="/dist/bignum/contribute">How to Contribute</a> </li> <li> <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/pjacklam/p5-bignum">Repository</a> </li> <li> <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=bignum">Issues</a> (1) </li> <li> <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=bignum+0.67" title="Matrix">Testers</a> <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/b/bignum.html?oncpan=1&amp;distmat=1&amp;version=0.67&amp;grade=2" style="color: #090">1657</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/b/bignum.html?oncpan=1&amp;distmat=1&amp;version=0.67&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/b/bignum.html?oncpan=1&amp;distmat=1&amp;version=0.67&amp;grade=4">0</a>)</span> </li> <li> <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/PJACKLAM/bignum-0.67">Kwalitee</a> </li> <li> <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on bignum who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)"> Bus factor: 5 </div> </li> <li> License: perl_5 </li> <li> Perl: v5.6.0 </li> <li class="nav-header">Activity</li> <li> <div class="activity-graph"> <img src="/dist/bignum/activity.svg?res=month" /> <div class="comment">24 month</div> </div> </li> <li class="nav-header">Tools</li> <li> <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/P/PJ/PJACKLAM/bignum-0.67.tar.gz"> Download (<span itemprop="fileSize">41.24KB</span>)</a> </li> <li> <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FPJACKLAM%2Fbignum-0.67%2Flib%2Fbigint.pm"> MetaCPAN Explorer </a> </li> <li> <a href="/dist/bignum/permissions"> Permissions </a> </li> <li> <a href="/dist/bignum/releases.rss"> Subscribe to distribution </a> </li> <li> <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog"> Install Instructions </button> </li> <li> <form action="/search"> <input type="hidden" name="q" value="dist:bignum"> <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form"> <input type="submit" style="display: none"> </form> </li> <li> <form action="https://grep.metacpan.org/search"> <input type="hidden" name="qd" value="bignum"> <input type="hidden" name="source" value="metacpan"> <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form"> <input type="submit" style="display: none"> </form> </li> <li class="version-jump"> <select class="select-navigator form-control tool-bar-form"> <option disabled selected>Jump to version</option> <option disabled value="/release/PJACKLAM/bignum-0.67/view/lib/bigint.pm" >0.67 (PJACKLAM on 2023-12-30)</option> <option value="/release/PJACKLAM/bignum-0.66/view/lib/bigint.pm" >0.66 (PJACKLAM on 2022-05-16)</option> <option value="/release/PJACKLAM/bignum-0.65/view/lib/bigint.pm" >0.65 (PJACKLAM on 2022-04-12)</option> <option value="/release/FLORA/bignum-0.32/view/lib/bigint.pm" >0.32 (FLORA on 2013-03-02)</option> <option value="/release/FLORA/bignum-0.30/view/lib/bigint.pm" >0.30 (FLORA on 2012-09-11)</option> <option value="/release/FLORA/bignum-0.29/view/lib/bigint.pm" >0.29 (FLORA on 2011-08-08)</option> <option value="/release/FLORA/bignum-0.28/view/lib/bigint.pm" >0.28 (FLORA on 2011-07-09)</option> <option value="/release/FLORA/bignum-0.25/view/lib/bigint.pm" >0.25 (FLORA on 2010-09-15)</option> <option value="/release/FLORA/bignum-0.24/view/lib/bigint.pm" >0.24 (FLORA on 2010-09-04)</option> <option value="/release/TELS/bignum-0.23/view/lib/bigint.pm" >0.23 (TELS on 2008-04-05)</option> <option value="/release/TELS/bignum-0.22/view/lib/bigint.pm" >0.22 (TELS on 2007-06-30)</option> <optgroup label="BackPAN">' <option value="/release/PJACKLAM/bignum-0.64/view/lib/bigint.pm" >0.64 (PJACKLAM on 2021-12-28)</option> <option value="/release/PJACKLAM/bignum-0.63/view/lib/bigint.pm" >0.63 (PJACKLAM on 2021-10-09)</option> <option value="/release/PJACKLAM/bignum-0.62/view/lib/bigint.pm" >0.62 (PJACKLAM on 2021-10-03)</option> <option value="/release/PJACKLAM/bignum-0.61/view/lib/bigint.pm" >0.61 (PJACKLAM on 2021-10-01)</option> <option value="/release/PJACKLAM/bignum-0.60/view/lib/bigint.pm" >0.60 (PJACKLAM on 2021-09-29)</option> <option value="/release/PJACKLAM/bignum-0.53/view/lib/bigint.pm" >0.53 (PJACKLAM on 2021-07-12)</option> <option value="/release/PJACKLAM/bignum-0.52/view/lib/bigint.pm" >0.52 (PJACKLAM on 2021-07-10)</option> <option value="/release/PJACKLAM/bignum-0.51/view/lib/bigint.pm" >0.51 (PJACKLAM on 2018-10-11)</option> <option value="/release/PJACKLAM/bignum-0.50/view/lib/bigint.pm" >0.50 (PJACKLAM on 2018-04-17)</option> <option value="/release/PJACKLAM/bignum-0.49/view/lib/bigint.pm" >0.49 (PJACKLAM on 2018-02-04)</option> <option value="/release/PJACKLAM/bignum-0.48/view/lib/bigint.pm" >0.48 (PJACKLAM on 2018-02-01)</option> <option value="/release/PJACKLAM/bignum-0.47/view/lib/bigint.pm" >0.47 (PJACKLAM on 2016-12-13)</option> <option value="/release/PJACKLAM/bignum-0.46/view/lib/bigint.pm" >0.46 (PJACKLAM on 2016-12-11)</option> <option value="/release/PJACKLAM/bignum-0.45/view/lib/bigint.pm" >0.45 (PJACKLAM on 2016-12-04)</option> <option value="/release/PJACKLAM/bignum-0.44/view/lib/bigint.pm" >0.44 (PJACKLAM on 2016-11-17)</option> <option value="/release/PJACKLAM/bignum-0.43/view/lib/bigint.pm" >0.43 (PJACKLAM on 2016-07-09)</option> <option value="/release/PJACKLAM/bignum-0.42/view/lib/bigint.pm" >0.42 (PJACKLAM on 2016-01-05)</option> <option value="/release/PJACKLAM/bignum-0.41/view/lib/bigint.pm" >0.41 (PJACKLAM on 2015-09-25)</option> <option value="/release/PJACKLAM/bignum-0.40/view/lib/bigint.pm" >0.40 (PJACKLAM on 2015-09-23)</option> <option value="/release/PJACKLAM/bignum-0.39/view/lib/bigint.pm" >0.39 (PJACKLAM on 2015-09-15)</option> <option value="/release/PJACKLAM/bignum-0.38/view/lib/bigint.pm" >0.38 (PJACKLAM on 2015-08-28)</option> <option value="/release/PJACKLAM/bignum-0.37/view/lib/bigint.pm" >0.37 (PJACKLAM on 2014-04-04)</option> <option value="/release/TELS/bignum-0.21/view/lib/bigint.pm" >0.21 (TELS on 2007-04-17)</option> <option value="/release/TELS/bignum-0.20/view/lib/bigint.pm" >0.20 (TELS on 2007-04-09)</option> <option value="/release/TELS/bignum-0.19/view/lib/bigint.pm" >0.19 (TELS on 2007-02-03)</option> <option value="/release/TELS/bignum-0.18/view/lib/bigint.pm" >0.18 (TELS on 2007-01-28)</option> <option value="/release/TELS/bignum-0.17/view/lib/bigint.pm" >0.17 (TELS on 2005-04-10)</option> <option value="/release/TELS/bignum-0.16/view/lib/bigint.pm" >0.16 (TELS on 2005-01-01)</option> <option value="/release/TELS/bignum-0.15/view/lib/bigint.pm" >0.15 (TELS on 2004-03-12)</option> <option value="/release/TELS/bignum-0.14/view/lib/bigint.pm" >0.14 (TELS on 2003-08-13)</option> <option value="/release/TELS/bignum-0.13/view/lib/bigint.pm" >0.13 (TELS on 2002-08-24)</option> <option value="/release/TELS/bignum-0.12/view/lib/bigint.pm" >0.12 (TELS on 2002-08-13)</option> <option value="/release/TELS/bignum-0.11/view/lib/bigint.pm" >0.11 (TELS on 2002-03-26)</option> <option value="/release/TELS/bignum-0.10/view/lib/bigint.pm" >0.10 (TELS on 2002-03-17)</option> <option value="/release/TELS/bignum-0.09/view/lib/bigint.pm" >0.09 (TELS on 2002-03-12)</option> <option value="/release/TELS/bignum-0.08/view/lib/bigint.pm" >0.08 (TELS on 2002-03-11)</option> <option value="/release/TELS/bignum-0.07/view/lib/bigint.pm" >0.07 (TELS on 2002-03-06)</option> <option value="/release/TELS/bignum-0.06/view/lib/bigint.pm" >0.06 (TELS on 2002-02-27)</option> </optgroup> </select> </li> <li class="version-diff"> <select class="select-navigator form-control tool-bar-form"> <option disabled selected>Diff with version</option> <option disabled value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.67/lib/bigint.pm" >0.67 (PJACKLAM on 2023-12-30)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.66/lib/bigint.pm" >0.66 (PJACKLAM on 2022-05-16)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.65/lib/bigint.pm" >0.65 (PJACKLAM on 2022-04-12)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/FLORA/bignum-0.32/lib/bigint.pm" >0.32 (FLORA on 2013-03-02)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/FLORA/bignum-0.30/lib/bigint.pm" >0.30 (FLORA on 2012-09-11)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/FLORA/bignum-0.29/lib/bigint.pm" >0.29 (FLORA on 2011-08-08)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/FLORA/bignum-0.28/lib/bigint.pm" >0.28 (FLORA on 2011-07-09)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/FLORA/bignum-0.25/lib/bigint.pm" >0.25 (FLORA on 2010-09-15)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/FLORA/bignum-0.24/lib/bigint.pm" >0.24 (FLORA on 2010-09-04)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.23/lib/bigint.pm" >0.23 (TELS on 2008-04-05)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.22/lib/bigint.pm" >0.22 (TELS on 2007-06-30)</option> <optgroup label="BackPAN">' <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.64/lib/bigint.pm" >0.64 (PJACKLAM on 2021-12-28)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.63/lib/bigint.pm" >0.63 (PJACKLAM on 2021-10-09)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.62/lib/bigint.pm" >0.62 (PJACKLAM on 2021-10-03)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.61/lib/bigint.pm" >0.61 (PJACKLAM on 2021-10-01)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.60/lib/bigint.pm" >0.60 (PJACKLAM on 2021-09-29)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.53/lib/bigint.pm" >0.53 (PJACKLAM on 2021-07-12)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.52/lib/bigint.pm" >0.52 (PJACKLAM on 2021-07-10)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.51/lib/bigint.pm" >0.51 (PJACKLAM on 2018-10-11)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.50/lib/bigint.pm" >0.50 (PJACKLAM on 2018-04-17)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.49/lib/bigint.pm" >0.49 (PJACKLAM on 2018-02-04)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.48/lib/bigint.pm" >0.48 (PJACKLAM on 2018-02-01)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.47/lib/bigint.pm" >0.47 (PJACKLAM on 2016-12-13)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.46/lib/bigint.pm" >0.46 (PJACKLAM on 2016-12-11)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.45/lib/bigint.pm" >0.45 (PJACKLAM on 2016-12-04)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.44/lib/bigint.pm" >0.44 (PJACKLAM on 2016-11-17)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.43/lib/bigint.pm" >0.43 (PJACKLAM on 2016-07-09)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.42/lib/bigint.pm" >0.42 (PJACKLAM on 2016-01-05)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.41/lib/bigint.pm" >0.41 (PJACKLAM on 2015-09-25)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.40/lib/bigint.pm" >0.40 (PJACKLAM on 2015-09-23)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.39/lib/bigint.pm" >0.39 (PJACKLAM on 2015-09-15)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.38/lib/bigint.pm" >0.38 (PJACKLAM on 2015-08-28)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/PJACKLAM/bignum-0.37/lib/bigint.pm" >0.37 (PJACKLAM on 2014-04-04)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.21/lib/bigint.pm" >0.21 (TELS on 2007-04-17)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.20/lib/bigint.pm" >0.20 (TELS on 2007-04-09)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.19/lib/bigint.pm" >0.19 (TELS on 2007-02-03)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.18/lib/bigint.pm" >0.18 (TELS on 2007-01-28)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.17/lib/bigint.pm" >0.17 (TELS on 2005-04-10)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.16/lib/bigint.pm" >0.16 (TELS on 2005-01-01)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.15/lib/bigint.pm" >0.15 (TELS on 2004-03-12)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.14/lib/bigint.pm" >0.14 (TELS on 2003-08-13)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.13/lib/bigint.pm" >0.13 (TELS on 2002-08-24)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.12/lib/bigint.pm" >0.12 (TELS on 2002-08-13)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.11/lib/bigint.pm" >0.11 (TELS on 2002-03-26)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.10/lib/bigint.pm" >0.10 (TELS on 2002-03-17)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.09/lib/bigint.pm" >0.09 (TELS on 2002-03-12)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.08/lib/bigint.pm" >0.08 (TELS on 2002-03-11)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.07/lib/bigint.pm" >0.07 (TELS on 2002-03-06)</option> <option value="/release/PJACKLAM/bignum-0.67/diff/TELS/bignum-0.06/lib/bigint.pm" >0.06 (TELS on 2002-02-27)</option> </optgroup> </select> </li> <li> <ul class="dependencies"> <li class="nav-header">Dependencies</li> <li><a href="/pod/Carp" title="Carp" class="ellipsis">Carp</a></li> <li><a href="/pod/Math::BigInt" title="Math::BigInt" class="ellipsis">Math::BigInt</a></li> <li><a href="/pod/Math::BigRat" title="Math::BigRat" class="ellipsis">Math::BigRat</a></li> <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li> <li> <hr> </li> <li> <a href="/module/bigint/requires">Reverse dependencies</a> </li> <li> <a href="http://deps.cpantesters.org/?module=bigint">CPAN Testers List</a> </li> <li> <a href="https://cpandeps.grinnz.com/?dist=bignum">Dependency graph</a> </li> </ul> </li> <li class="nav-header">Permalinks</li> <li> <a href="/release/PJACKLAM/bignum-0.67/view/lib/bigint.pm">This version</a> </li> <li> <a href="/pod/bigint">Latest version</a> </li> <li> <div class="plussers"> <div class="nav-header">++ed by:</div> <div> <a class="display-all" href="/author/PAWAPAWA"><img src="https://www.gravatar.com/avatar/96d37e9730b6fe228338ce866c103daa?d=identicon&amp;s=20" title="PAWAPAWA" alt="PAWAPAWA"></a> <a class="display-all" href="/author/NGLENN"><img src="https://www.gravatar.com/avatar/d760ed3250a704f6ae9e2c9b4d73cc1f?d=identicon&amp;s=20" title="NGLENN" alt="NGLENN"></a> <a class="display-all" href="/author/PINGAN"><img src="https://www.gravatar.com/avatar/a02222e5e0e4fd24d52fc29a08ac6bcb?d=identicon&amp;s=20" title="PINGAN" alt="PINGAN"></a> </div> <!-- Display counts of plussers--> <div> <a href="/dist/bignum/plussers">3 PAUSE users</a> </div> <div> 1 non-PAUSE user </div> </div> </li> <li> </li> </ul> </div> </nav> <div class="content-navigation"> <div class="breadcrumbs"> <span> <a data-keyboard-shortcut="g a" rel="author" href="/author/PJACKLAM" class="author-name">Peter John Acklam</a> </span> <span>&nbsp;/&nbsp;</span> <div class="release dist-release status-latest maturity-released"> <span class="dropdown"><b class="caret"></b></span> <select class="select-navigator "> <option selected value="/release/PJACKLAM/bignum-0.67/view/lib/bigint.pm" >0.67 (PJACKLAM on 2023-12-30)</option> <option value="/release/PJACKLAM/bignum-0.66/view/lib/bigint.pm" >0.66 (PJACKLAM on 2022-05-16)</option> <option value="/release/PJACKLAM/bignum-0.65/view/lib/bigint.pm" >0.65 (PJACKLAM on 2022-04-12)</option> <option value="/release/FLORA/bignum-0.32/view/lib/bigint.pm" >0.32 (FLORA on 2013-03-02)</option> <option value="/release/FLORA/bignum-0.30/view/lib/bigint.pm" >0.30 (FLORA on 2012-09-11)</option> <option value="/release/FLORA/bignum-0.29/view/lib/bigint.pm" >0.29 (FLORA on 2011-08-08)</option> <option value="/release/FLORA/bignum-0.28/view/lib/bigint.pm" >0.28 (FLORA on 2011-07-09)</option> <option value="/release/FLORA/bignum-0.25/view/lib/bigint.pm" >0.25 (FLORA on 2010-09-15)</option> <option value="/release/FLORA/bignum-0.24/view/lib/bigint.pm" >0.24 (FLORA on 2010-09-04)</option> <option value="/release/TELS/bignum-0.23/view/lib/bigint.pm" >0.23 (TELS on 2008-04-05)</option> <option value="/release/TELS/bignum-0.22/view/lib/bigint.pm" >0.22 (TELS on 2007-06-30)</option> <optgroup label="BackPAN">' <option value="/release/PJACKLAM/bignum-0.64/view/lib/bigint.pm" >0.64 (PJACKLAM on 2021-12-28)</option> <option value="/release/PJACKLAM/bignum-0.63/view/lib/bigint.pm" >0.63 (PJACKLAM on 2021-10-09)</option> <option value="/release/PJACKLAM/bignum-0.62/view/lib/bigint.pm" >0.62 (PJACKLAM on 2021-10-03)</option> <option value="/release/PJACKLAM/bignum-0.61/view/lib/bigint.pm" >0.61 (PJACKLAM on 2021-10-01)</option> <option value="/release/PJACKLAM/bignum-0.60/view/lib/bigint.pm" >0.60 (PJACKLAM on 2021-09-29)</option> <option value="/release/PJACKLAM/bignum-0.53/view/lib/bigint.pm" >0.53 (PJACKLAM on 2021-07-12)</option> <option value="/release/PJACKLAM/bignum-0.52/view/lib/bigint.pm" >0.52 (PJACKLAM on 2021-07-10)</option> <option value="/release/PJACKLAM/bignum-0.51/view/lib/bigint.pm" >0.51 (PJACKLAM on 2018-10-11)</option> <option value="/release/PJACKLAM/bignum-0.50/view/lib/bigint.pm" >0.50 (PJACKLAM on 2018-04-17)</option> <option value="/release/PJACKLAM/bignum-0.49/view/lib/bigint.pm" >0.49 (PJACKLAM on 2018-02-04)</option> <option value="/release/PJACKLAM/bignum-0.48/view/lib/bigint.pm" >0.48 (PJACKLAM on 2018-02-01)</option> <option value="/release/PJACKLAM/bignum-0.47/view/lib/bigint.pm" >0.47 (PJACKLAM on 2016-12-13)</option> <option value="/release/PJACKLAM/bignum-0.46/view/lib/bigint.pm" >0.46 (PJACKLAM on 2016-12-11)</option> <option value="/release/PJACKLAM/bignum-0.45/view/lib/bigint.pm" >0.45 (PJACKLAM on 2016-12-04)</option> <option value="/release/PJACKLAM/bignum-0.44/view/lib/bigint.pm" >0.44 (PJACKLAM on 2016-11-17)</option> <option value="/release/PJACKLAM/bignum-0.43/view/lib/bigint.pm" >0.43 (PJACKLAM on 2016-07-09)</option> <option value="/release/PJACKLAM/bignum-0.42/view/lib/bigint.pm" >0.42 (PJACKLAM on 2016-01-05)</option> <option value="/release/PJACKLAM/bignum-0.41/view/lib/bigint.pm" >0.41 (PJACKLAM on 2015-09-25)</option> <option value="/release/PJACKLAM/bignum-0.40/view/lib/bigint.pm" >0.40 (PJACKLAM on 2015-09-23)</option> <option value="/release/PJACKLAM/bignum-0.39/view/lib/bigint.pm" >0.39 (PJACKLAM on 2015-09-15)</option> <option value="/release/PJACKLAM/bignum-0.38/view/lib/bigint.pm" >0.38 (PJACKLAM on 2015-08-28)</option> <option value="/release/PJACKLAM/bignum-0.37/view/lib/bigint.pm" >0.37 (PJACKLAM on 2014-04-04)</option> <option value="/release/TELS/bignum-0.21/view/lib/bigint.pm" >0.21 (TELS on 2007-04-17)</option> <option value="/release/TELS/bignum-0.20/view/lib/bigint.pm" >0.20 (TELS on 2007-04-09)</option> <option value="/release/TELS/bignum-0.19/view/lib/bigint.pm" >0.19 (TELS on 2007-02-03)</option> <option value="/release/TELS/bignum-0.18/view/lib/bigint.pm" >0.18 (TELS on 2007-01-28)</option> <option value="/release/TELS/bignum-0.17/view/lib/bigint.pm" >0.17 (TELS on 2005-04-10)</option> <option value="/release/TELS/bignum-0.16/view/lib/bigint.pm" >0.16 (TELS on 2005-01-01)</option> <option value="/release/TELS/bignum-0.15/view/lib/bigint.pm" >0.15 (TELS on 2004-03-12)</option> <option value="/release/TELS/bignum-0.14/view/lib/bigint.pm" >0.14 (TELS on 2003-08-13)</option> <option value="/release/TELS/bignum-0.13/view/lib/bigint.pm" >0.13 (TELS on 2002-08-24)</option> <option value="/release/TELS/bignum-0.12/view/lib/bigint.pm" >0.12 (TELS on 2002-08-13)</option> <option value="/release/TELS/bignum-0.11/view/lib/bigint.pm" >0.11 (TELS on 2002-03-26)</option> <option value="/release/TELS/bignum-0.10/view/lib/bigint.pm" >0.10 (TELS on 2002-03-17)</option> <option value="/release/TELS/bignum-0.09/view/lib/bigint.pm" >0.09 (TELS on 2002-03-12)</option> <option value="/release/TELS/bignum-0.08/view/lib/bigint.pm" >0.08 (TELS on 2002-03-11)</option> <option value="/release/TELS/bignum-0.07/view/lib/bigint.pm" >0.07 (TELS on 2002-03-06)</option> <option value="/release/TELS/bignum-0.06/view/lib/bigint.pm" >0.06 (TELS on 2002-02-27)</option> </optgroup> </select> <a data-keyboard-shortcut="g d" class="release-name" href="/dist/bignum">bignum-0.67</a> </div> <span class="river-gauge-gauge"> <svg width="24px" height="15px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <title> River stage three &#10; • 31 direct dependents &#10; • 494 total dependents </title> <rect x="0" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="5" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="10" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="15" y="0" width="4" height="15" fill="#e4e2e2" /> <rect x="20" y="0" width="4" height="15" fill="#e4e2e2" /> </g> </svg> </span> <div id="bignum-fav" class="show-logged-in"> <form action="/account/favorite/add" style="display: inline" method="POST"> <input type="hidden" name="remove" value="0"> <input type="hidden" name="release" value="bignum-0.67"> <input type="hidden" name="author" value="PJACKLAM"> <input type="hidden" name="distribution" value="bignum"> <button type="submit" class="favorite highlight"><span>4</span> ++</button> </form> </div> <div class="show-logged-out"> <button class="fav-not-logged-in favorite highlight"><span>4</span> ++</button> </div> / <span>bigint</span> </div> </div> <main class="content"> <nav class="toc"> <div class="toc-header"><strong>Contents</strong></div> <ul> <li><a href="#NAME">NAME</a></li> <li><a href="#SYNOPSIS">SYNOPSIS</a></li> <li><a href="#DESCRIPTION">DESCRIPTION</a> <ul> <li><a href="#use-integer-vs.-use-bigint">use integer vs. use bigint</a></li> <li><a href="#Options">Options</a></li> <li><a href="#Math-Library">Math Library</a></li> <li><a href="#Method-calls">Method calls</a></li> <li><a href="#Methods">Methods</a></li> </ul> </li> <li><a href="#CAVEATS">CAVEATS</a></li> <li><a href="#EXAMPLES">EXAMPLES</a></li> <li><a href="#BUGS">BUGS</a></li> <li><a href="#SUPPORT">SUPPORT</a></li> <li><a href="#LICENSE">LICENSE</a></li> <li><a href="#SEE-ALSO">SEE ALSO</a></li> <li><a href="#AUTHORS">AUTHORS</a></li> </ul></nav> <div class="pod anchors"> <h1 id="NAME">NAME</h1> <p>bigint - transparent big integer support for Perl</p> <h1 id="SYNOPSIS">SYNOPSIS</h1> <pre><code>use bigint; $x = 2 + 4.5; # Math::BigInt 6 print 2 ** 512; # Math::BigInt 134...096 print inf + 42; # Math::BigInt inf print NaN * 7; # Math::BigInt NaN print hex(&quot;0x1234567890123490&quot;); # Perl v5.10.0 or later { no bigint; print 2 ** 256; # a normal Perl scalar now } # for older Perls, import into current package: use bigint qw/hex oct/; print hex(&quot;0x1234567890123490&quot;); print oct(&quot;01234567890123490&quot;);</code></pre> <h1 id="DESCRIPTION">DESCRIPTION</h1> <p>All numeric literal in the given scope are converted to Math::BigInt objects. Numeric literal that represent non-integers are truncated to an integer. All results of expressions are also truncated to integer.</p> <p>All operators (including basic math operations) except the range operator <code>..</code> are overloaded.</p> <p>Unlike the <a href="/pod/integer">integer</a> pragma, the <code>bigint</code> pragma creates integers that are only limited in their size by the available memory.</p> <p>So, the following:</p> <pre><code>use bigint; $x = 1234;</code></pre> <p>creates a Math::BigInt and stores a reference to in $x. This happens transparently and behind your back, so to speak.</p> <p>You can see this with the following:</p> <pre><code>perl -Mbigint -le &#39;print ref(1234)&#39;</code></pre> <p>Since numbers are actually objects, you can call all the usual methods from Math::BigFloat on them. This even works to some extent on expressions:</p> <pre><code>perl -Mbigint -le &#39;$x = 1234; print $x-&gt;bdec()&#39; perl -Mbigint -le &#39;print 1234-&gt;copy()-&gt;binc();&#39; perl -Mbigint -le &#39;print 1234-&gt;copy()-&gt;binc-&gt;badd(6);&#39; perl -Mbigint -le &#39;print +(1234)-&gt;copy()-&gt;binc()&#39;</code></pre> <p>(Note that print doesn&#39;t do what you expect if the expression starts with &#39;(&#39; hence the <code>+</code>)</p> <p>You can even chain the operations together as usual:</p> <pre><code>perl -Mbigint -le &#39;print 1234-&gt;copy()-&gt;binc-&gt;badd(6);&#39; 1241</code></pre> <p>Please note the following does not work as expected (prints nothing), since overloading of &#39;..&#39; is not yet possible in Perl (as of v5.8.0):</p> <pre><code>perl -Mbigint -le &#39;for (1..2) { print ref($_); }&#39;</code></pre> <h2 id="use-integer-vs.-use-bigint"><a id="use"></a>use integer vs. use bigint</h2> <p>There are some difference between <code>use integer</code> and <code>use bigint</code>.</p> <p>Whereas <code>use integer</code> is limited to what can be handled as a Perl scalar, <code>use bigint</code> can handle arbitrarily large integers.</p> <p>Also, <code>use integer</code> does affect assignments to variables and the return value of some functions. <code>use bigint</code> truncates these results to integer:</p> <pre><code># perl -Minteger -wle &#39;print 3.2&#39; 3.2 # perl -Minteger -wle &#39;print 3.2 + 0&#39; 3 # perl -Mbigint -wle &#39;print 3.2&#39; 3 # perl -Mbigint -wle &#39;print 3.2 + 0&#39; 3 # perl -Mbigint -wle &#39;print exp(1) + 0&#39; 2 # perl -Mbigint -wle &#39;print exp(1)&#39; 2 # perl -Minteger -wle &#39;print exp(1)&#39; 2.71828182845905 # perl -Minteger -wle &#39;print exp(1) + 0&#39; 2</code></pre> <p>In practice this seldom makes a difference for small integers as <b>parts and results</b> of expressions are truncated anyway, but this can, for instance, affect the return value of subroutines:</p> <pre><code>sub three_integer { use integer; return 3.2; } sub three_bigint { use bigint; return 3.2; } print three_integer(), &quot; &quot;, three_bigint(),&quot;\n&quot;; # prints &quot;3.2 3&quot;</code></pre> <h2 id="Options">Options</h2> <p><code>bigint</code> recognizes some options that can be passed while loading it via <code>use</code>. The following options exist:</p> <dl> <dt id="a-or-accuracy"><a id="a"></a>a or accuracy</dt> <dd> <p>This sets the accuracy for all math operations. The argument must be greater than or equal to zero. See Math::BigInt&#39;s bround() method for details.</p> <pre><code>perl -Mbigint=a,2 -le &#39;print 12345+1&#39;</code></pre> <p>Note that setting precision and accuracy at the same time is not possible.</p> </dd> <dt id="p-or-precision"><a id="p"></a>p or precision</dt> <dd> <p>This sets the precision for all math operations. The argument can be any integer. Negative values mean a fixed number of digits after the dot, and are ignored since all operations happen in integer space. A positive value rounds to this digit left from the dot. 0 means round to integer. See Math::BigInt&#39;s bfround() method for details.</p> <pre><code>perl -mbigint=p,5 -le &#39;print 123456789+123&#39;</code></pre> <p>Note that setting precision and accuracy at the same time is not possible.</p> </dd> <dt id="t-or-trace"><a id="t"></a>t or trace</dt> <dd> <p>This enables a trace mode and is primarily for debugging.</p> </dd> <dt id="l,-lib,-try,-or-only"><a id="l"></a><a id="l-lib-try-or-only"></a>l, lib, try, or only</dt> <dd> <p>Load a different math lib, see <a href="#Math-Library">&quot;Math Library&quot;</a>.</p> <pre><code>perl -Mbigint=l,GMP -e &#39;print 2 ** 512&#39; perl -Mbigint=lib,GMP -e &#39;print 2 ** 512&#39; perl -Mbigint=try,GMP -e &#39;print 2 ** 512&#39; perl -Mbigint=only,GMP -e &#39;print 2 ** 512&#39;</code></pre> </dd> <dt id="hex">hex</dt> <dd> <p>Override the built-in hex() method with a version that can handle big numbers. This overrides it by exporting it to the current package. Under Perl v5.10.0 and higher, this is not necessary, as hex() is lexically overridden in the current scope whenever the <code>bigint</code> pragma is active.</p> </dd> <dt id="oct">oct</dt> <dd> <p>Override the built-in oct() method with a version that can handle big numbers. This overrides it by exporting it to the current package. Under Perl v5.10.0 and higher, this is not so necessary, as oct() is lexically overridden in the current scope whenever the <code>bigint</code> pragma is active.</p> </dd> <dt id="v-or-version"><a id="v"></a>v or version</dt> <dd> <p>this prints out the name and version of the modules and then exits.</p> <pre><code>perl -Mbigint=v</code></pre> </dd> </dl> <h2 id="Math-Library"><a id="Math"></a>Math Library</h2> <p>Math with the numbers is done (by default) by a backend library module called Math::BigInt::Calc. The default is equivalent to saying:</p> <pre><code>use bigint lib =&gt; &#39;Calc&#39;;</code></pre> <p>you can change this by using:</p> <pre><code>use bigint lib =&gt; &#39;GMP&#39;;</code></pre> <p>The following would first try to find Math::BigInt::Foo, then Math::BigInt::Bar, and if this also fails, revert to Math::BigInt::Calc:</p> <pre><code>use bigint lib =&gt; &#39;Foo,Math::BigInt::Bar&#39;;</code></pre> <p>Using c&lt;lib&gt; warns if none of the specified libraries can be found and <a href="/pod/Math::BigInt">Math::BigInt</a> fell back to one of the default libraries. To suppress this warning, use c&lt;try&gt; instead:</p> <pre><code>use bigint try =&gt; &#39;GMP&#39;;</code></pre> <p>If you want the code to die instead of falling back, use <code>only</code> instead:</p> <pre><code>use bigint only =&gt; &#39;GMP&#39;;</code></pre> <p>Please see the respective module documentation for further details.</p> <h2 id="Method-calls"><a id="Method"></a>Method calls</h2> <p>Since all numbers are now objects, you can use all methods that are part of the Math::BigInt API.</p> <p>But a warning is in order. When using the following to make a copy of a number, only a shallow copy will be made.</p> <pre><code>$x = 9; $y = $x; $x = $y = 7;</code></pre> <p>Using the copy or the original with overloaded math is okay, e.g., the following work:</p> <pre><code>$x = 9; $y = $x; print $x + 1, &quot; &quot;, $y,&quot;\n&quot;; # prints 10 9</code></pre> <p>but calling any method that modifies the number directly will result in <b>both</b> the original and the copy being destroyed:</p> <pre><code>$x = 9; $y = $x; print $x-&gt;badd(1), &quot; &quot;, $y,&quot;\n&quot;; # prints 10 10 $x = 9; $y = $x; print $x-&gt;binc(1), &quot; &quot;, $y,&quot;\n&quot;; # prints 10 10 $x = 9; $y = $x; print $x-&gt;bmul(2), &quot; &quot;, $y,&quot;\n&quot;; # prints 18 18</code></pre> <p>Using methods that do not modify, but test that the contents works:</p> <pre><code>$x = 9; $y = $x; $z = 9 if $x-&gt;is_zero(); # works fine</code></pre> <p>See the documentation about the copy constructor and <code>=</code> in overload, as well as the documentation in Math::BigInt for further details.</p> <h2 id="Methods">Methods</h2> <dl> <dt id="inf()"><a id="inf"></a>inf()</dt> <dd> <p>A shortcut to return Math::BigInt-&gt;binf(). Useful because Perl does not always handle bareword <code>inf</code> properly.</p> </dd> <dt id="NaN()"><a id="NaN"></a>NaN()</dt> <dd> <p>A shortcut to return Math::BigInt-&gt;bnan(). Useful because Perl does not always handle bareword <code>NaN</code> properly.</p> </dd> <dt id="e">e</dt> <dd> <pre><code># perl -Mbigint=e -wle &#39;print e&#39;</code></pre> <p>Returns Euler&#39;s number <code>e</code>, aka exp(1). Note that under <code>bigint</code>, this is truncated to an integer, i.e., 2.</p> </dd> <dt id="PI">PI</dt> <dd> <pre><code># perl -Mbigint=PI -wle &#39;print PI&#39;</code></pre> <p>Returns PI. Note that under <code>bigint</code>, this is truncated to an integer, i.e., 3.</p> </dd> <dt id="bexp()"><a id="bexp"></a>bexp()</dt> <dd> <pre><code>bexp($power, $accuracy);</code></pre> <p>Returns Euler&#39;s number <code>e</code> raised to the appropriate power, to the wanted accuracy.</p> <p>Note that under <code>bigint</code>, the result is truncated to an integer.</p> <p>Example:</p> <pre><code># perl -Mbigint=bexp -wle &#39;print bexp(1,80)&#39;</code></pre> </dd> <dt id="bpi()"><a id="bpi"></a>bpi()</dt> <dd> <pre><code>bpi($accuracy);</code></pre> <p>Returns PI to the wanted accuracy. Note that under <code>bigint</code>, this is truncated to an integer, i.e., 3.</p> <p>Example:</p> <pre><code># perl -Mbigint=bpi -wle &#39;print bpi(80)&#39;</code></pre> </dd> <dt id="accuracy()"><a id="accuracy"></a>accuracy()</dt> <dd> <p>Set or get the accuracy.</p> </dd> <dt id="precision()"><a id="precision"></a>precision()</dt> <dd> <p>Set or get the precision.</p> </dd> <dt id="round_mode()"><a id="round_mode"></a>round_mode()</dt> <dd> <p>Set or get the rounding mode.</p> </dd> <dt id="div_scale()"><a id="div_scale"></a>div_scale()</dt> <dd> <p>Set or get the division scale.</p> </dd> <dt id="in_effect()"><a id="in_effect"></a>in_effect()</dt> <dd> <pre><code>use bigint; print &quot;in effect\n&quot; if bigint::in_effect; # true { no bigint; print &quot;in effect\n&quot; if bigint::in_effect; # false }</code></pre> <p>Returns true or false if <code>bigint</code> is in effect in the current scope.</p> <p>This method only works on Perl v5.9.4 or later.</p> </dd> </dl> <h1 id="CAVEATS">CAVEATS</h1> <dl> <dt id="Hexadecimal,-octal,-and-binary-floating-point-literals"><a id="Hexadecimal"></a><a id="Hexadecimal-octal-and-binary-floating-point-literals"></a>Hexadecimal, octal, and binary floating point literals</dt> <dd> <p>Perl (and this module) accepts hexadecimal, octal, and binary floating point literals, but use them with care with Perl versions before v5.32.0, because some versions of Perl silently give the wrong result.</p> </dd> <dt id="Operator-vs-literal-overloading"><a id="Operator"></a>Operator vs literal overloading</dt> <dd> <p><code>bigint</code> works by overloading handling of integer and floating point literals, converting them to <a href="/pod/Math::BigInt">Math::BigInt</a> objects.</p> <p>This means that arithmetic involving only string values or string literals are performed using Perl&#39;s built-in operators.</p> <p>For example:</p> <pre><code>use bigint; my $x = &quot;900000000000000009&quot;; my $y = &quot;900000000000000007&quot;; print $x - $y;</code></pre> <p>outputs <code>0</code> on default 32-bit builds, since <code>bigint</code> never sees the string literals. To ensure the expression is all treated as <code>Math::BigInt</code> objects, use a literal number in the expression:</p> <pre><code>print +(0+$x) - $y;</code></pre> </dd> <dt id="Ranges">Ranges</dt> <dd> <p>Perl does not allow overloading of ranges, so you can neither safely use ranges with <code>bigint</code> endpoints, nor is the iterator variable a <code>Math::BigInt</code>.</p> <pre><code>use 5.010; for my $i (12..13) { for my $j (20..21) { say $i ** $j; # produces a floating-point number, # not an object } }</code></pre> </dd> <dt id="in_effect()1"><a id="in_effect1"></a>in_effect()</dt> <dd> <p>This method only works on Perl v5.9.4 or later.</p> </dd> <dt id="hex()/oct()"><a id="hex1"></a><a id="hex-oct"></a>hex()/oct()</dt> <dd> <p><code>bigint</code> overrides these routines with versions that can also handle big integer values. Under Perl prior to version v5.9.4, however, this will not happen unless you specifically ask for it with the two import tags &quot;hex&quot; and &quot;oct&quot; - and then it will be global and cannot be disabled inside a scope with <code>no bigint</code>:</p> <pre><code>use bigint qw/hex oct/; print hex(&quot;0x1234567890123456&quot;); { no bigint; print hex(&quot;0x1234567890123456&quot;); }</code></pre> <p>The second call to hex() will warn about a non-portable constant.</p> <p>Compare this to:</p> <pre><code>use bigint; # will warn only under Perl older than v5.9.4 print hex(&quot;0x1234567890123456&quot;);</code></pre> </dd> </dl> <h1 id="EXAMPLES">EXAMPLES</h1> <p>Some cool command line examples to impress the Python crowd ;) You might want to compare them to the results under -Mbigfloat or -Mbigrat:</p> <pre><code>perl -Mbigint -le &#39;print sqrt(33)&#39; perl -Mbigint -le &#39;print 2**255&#39; perl -Mbigint -le &#39;print 4.5+2**255&#39; perl -Mbigint -le &#39;print 123-&gt;is_odd()&#39; perl -Mbigint=l,GMP -le &#39;print 7 ** 7777&#39;</code></pre> <h1 id="BUGS">BUGS</h1> <p>Please report any bugs or feature requests to <code>bug-bignum at rt.cpan.org</code>, or through the web interface at <a href="https://rt.cpan.org/Ticket/Create.html?Queue=bignum">https://rt.cpan.org/Ticket/Create.html?Queue=bignum</a> (requires login). We will be notified, and then you&#39;ll automatically be notified of progress on your bug as I make changes.</p> <h1 id="SUPPORT">SUPPORT</h1> <p>You can find documentation for this module with the perldoc command.</p> <pre><code>perldoc bigint</code></pre> <p>You can also look for information at:</p> <ul> <li><p>GitHub</p> <p><a href="https://github.com/pjacklam/p5-bignum">https://github.com/pjacklam/p5-bignum</a></p> </li> <li><p>RT: CPAN&#39;s request tracker</p> <p><a href="https://rt.cpan.org/Dist/Display.html?Name=bignum">https://rt.cpan.org/Dist/Display.html?Name=bignum</a></p> </li> <li><p>MetaCPAN</p> <p><a href="https://metacpan.org/release/bignum">https://metacpan.org/release/bignum</a></p> </li> <li><p>CPAN Testers Matrix</p> <p><a href="http://matrix.cpantesters.org/?dist=bignum">http://matrix.cpantesters.org/?dist=bignum</a></p> </li> </ul> <h1 id="LICENSE">LICENSE</h1> <p>This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.</p> <h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1> <p><a href="/pod/bignum">bignum</a> and <a href="/pod/bigrat">bigrat</a>.</p> <p><a href="/pod/Math::BigInt">Math::BigInt</a>, <a href="/pod/Math::BigFloat">Math::BigFloat</a>, <a href="/pod/Math::BigRat">Math::BigRat</a> and <a href="/pod/Math::Big">Math::Big</a> as well as <a href="/pod/Math::BigInt::FastCalc">Math::BigInt::FastCalc</a>, <a href="/pod/Math::BigInt::Pari">Math::BigInt::Pari</a> and <a href="/pod/Math::BigInt::GMP">Math::BigInt::GMP</a>.</p> <h1 id="AUTHORS">AUTHORS</h1> <ul> <li><p>(C) by Tels <a href="http://bloodgate.com/">http://bloodgate.com/</a> in early 2002 - 2007.</p> </li> <li><p>Maintained by Peter John Acklam &lt;pjacklam@gmail.com&gt;, 2014-.</p> </li> </ul></div> <div id="metacpan_install-instructions-dialog" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">Module Install Instructions</h4> </div> <div class="modal-body"> <p>To install bignum, copy and paste the appropriate command in to your terminal.</p> <p><a href="/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p> <pre><code>cpanm bignum</code></pre> <p><a href="/pod/CPAN">CPAN shell</a></p> <pre><code>perl -MCPAN -e shell install bignum</code></pre> <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p> </div> <div class="modal-footer"> <a href="#" data-dismiss="modal" class="btn">Close</a> </div> </div> </div> </div> </main> <div class="content-pagination"> </div> </div> <footer class="footer"> <div class="footer-container"> <div class="footer-social"> <div class="footer-link footer-logo"> <a href="/"> <img src="/static/images/metacpan-logo.svg" alt="MetaCPAN" /> </a> </div> <a class="footer-social-link" href="https://github.com/metacpan"> <i class="fab fa-github-square"></i> </a> <a class="footer-social-link" href="https://fosstodon.org/@metacpan"> <i class="fab fa-mastodon"></i> </a> </div> <div class="footer-links"> <div class="footer-link"> <a href="/about">About</a> </div> <div class="footer-link"> <a href="/about/sponsors">Sponsor</a> </div> <div class="footer-link"> <a href="https://grep.metacpan.org">grep::cpan</a> </div> <div class="footer-link"> <a href="/recent">Recent</a> </div> <div class="footer-link"> <a href="/about/faq">FAQ</a> </div> <div class="footer-link"> <a href="/tools">Tools</a> </div> <div class="footer-link"> <a href="https://fastapi.metacpan.org/">API</a> </div> <div class="footer-link"> <a href="https://www.perl.org/">Perl.org</a> </div> </div> <div class="footer-sponsors"> <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener"> <img class="footer-sponsor-bytemark" src="/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener"> <img class="footer-sponsor-liquidweb" src="/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener"> <img class="footer-sponsor-deriv" src="/static/images/sponsors/deriv.svg" alt="Deriv logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener"> <img class="footer-sponsor-geocode" src="/static/images/sponsors/geocodelogo.svg" alt="Geocode logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener"> <img class="footer-sponsor-fastly" src="/static/images/sponsors/fastly_logo.svg" alt="Fastly logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener"> <img class="footer-sponsor-opencage" src="/static/images/sponsors/open-cage.svg" alt="OpenCage logo"> </a> <!-- Added 2024-07-22 --> <a class="footer-sponsor-link" target="_blank" href="https://www.elastic.co/" rel="noopener"> <img class="footer-sponsor-elastic" src="/static/images/sponsors/elastic.svg" alt="Elastic logo"> </a> <!-- Added 2024-07-22 --> <a class="footer-sponsor-link" target="_blank" href="https://route4me.com/" rel="noopener"> <img class="footer-sponsor-route4me" src="/static/images/sponsors/route4me.png" alt="Route4Me logo"> </a> </div> </div> </footer> <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Keyboard Shortcuts</h4> </div> <div class="modal-body row"> <div class="col-md-6"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>Global</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>s</kbd> </td> <td>Focus search bar</td> </tr> <tr> <td class="keys"> <kbd>?</kbd> </td> <td>Bring up this help dialog</td> </tr> </tbody> </table> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>GitHub</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>g</kbd> <kbd>p</kbd> </td> <td>Go to pull requests</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>i</kbd> </td> <td>go to github issues (only if github is preferred repository)</td> </tr> </tbody> </table> </div> <div class="col-md-6"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>POD</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>g</kbd> <kbd>a</kbd> </td> <td>Go to author</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>c</kbd> </td> <td>Go to changes</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>i</kbd> </td> <td>Go to issues</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>d</kbd> </td> <td>Go to dist</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>r</kbd> </td> <td>Go to repository/SCM</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>s</kbd> </td> <td>Go to source</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>b</kbd> </td> <td>Go to file browse</td> </tr> </tbody> </table> </div> <div class="col-md-12"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>Search terms</th> </tr> </thead> <tbody> <tr> <td><em>module:</em> (e.g. <a href="/search?q=module%3APlugin">module:Plugin</a>)</td> </tr> <tr> <td><em>distribution:</em> (e.g. <a href="/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td> </tr> <tr> <td><em>author:</em> (e.g. <a href="/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td> </tr> <tr> <td><em>version:</em> (e.g. <a href="/search?q=version%3A1.00">version:1.00</a>)</td> </tr> </tbody> </table> </div> </div> <div class="modal-footer"></div> </div> </div> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10