MATH::BIGINT::CALC(3pm)

πŸ’… Math::BigInt::Calc

okay so bestie, this is a manual page for the module Math::BigInt::Calc β€” it's the pure Perl module that supports Math::BigInt. no cap, it's the backend that does the actual number crunching when you don't have some fancy compiled library loaded. 🫢


🌸 SYNOPSIS 🌸

here's how you'd actually use it, in all the ways:

# to use it with Math::BigInt
use Math::BigInt lib => 'Calc';

# to use it with Math::BigFloat
use Math::BigFloat lib => 'Calc';

# to use it with Math::BigRat
use Math::BigRat lib => 'Calc';

# explicitly set base length and whether to "use integer"
use Math::BigInt::Calc base_len => 4, use_int => 1;
use Math::BigInt lib => 'Calc';

like literally just pick your vibe and go ✨


πŸ’– DESCRIPTION πŸ’–

Math::BigInt::Calc inherits from Math::BigInt::Lib. family tree moment πŸ‘‘

so the way this library works: numbers are represented internally in base B = 10**N, where N is the largest possible integer that doesn't cause overflow in the intermediate computations. it's giving "maximum safe vibes" πŸ¦‹

the base B elements live in an array, and the least significant element is stored in array element zero. like, index 0 is the littlest guy. humbling. there are no leading zero elements β€” except a single zero element when the number is zero (iconic exception, we stan) πŸ’€

for instance, if B = 10000, the number 1234567890 is represented internally as [7890, 3456, 12].

see how it's chunked up? ate and left no crumbs πŸ“


✨ OPTIONS ✨

when the module is loaded, it computes the maximum exponent β€” i.e. the power of 10 β€” that can be used with and without "use integer" in the computations. the default is to use this maximum exponent. πŸ”₯

⚠️ heads up bestie: if the combination of the 'base_len' value and the 'use_int' value exceeds the maximum value, an error is thrown. not a drill, it will literally fail on you 😭

πŸŽ€ base_len

you can specify the base length explicitly with the 'base_len' option. the value must be a positive integer.

use Math::BigInt::Calc base_len => 4;  # use 10000 as internal base

πŸŽ€ use_int

this one's for saying whether "use integer" should be used in the internal computations. the value is interpreted as a boolean, so use 0 or "" for false, and literally anything else for true. πŸ™ˆ

if 'base_len' isn't specified together with 'use_int', the current value for the base length is used.

use Math::BigInt::Calc use_int => 1;   # use "use integer" internally

🌈 METHODS 🌈

okay so this overview contains only the methods that are specific to Math::BigInt::Calc. for the other methods, go look at Math::BigInt::Lib (iykyk) πŸ“š

πŸ¦‹ _base_len()

specify the desired base length and whether to enable "use integer" in the computations.

Math::BigInt::Calc -> _base_len($base_len, $use_int);
πŸ’‘ lowkey important: it's better to specify the base length and whether to use integers as options when the module is loaded, like this:
use Math::BigInt::Calc base_len => 6, use_int => 1;

main character energy is passing the options at load time, not calling the method later. periodt. πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

  • Math::BigInt::Lib β€” for a description of the API.
  • alternative libraries: Math::BigInt::FastCalc, Math::BigInt::GMP, Math::BigInt::Pari, Math::BigInt::GMPz, and Math::BigInt::BitVect. ✨
  • some of the modules that use these libraries: Math::BigInt, Math::BigFloat, and Math::BigRat. 🫢

and that's the whole page, bestie πŸ’œ this was perl v5.42.3, dated 2026-11-03 β€” so go forth, chunk your digits in base 10**N, and slay 🌸🧚⭐

πŸ“¦ where this page comes from