in reply to Re: bc within perl
in thread bc within perl

I did try BigInt prior to this. That has a restriction of 64bit binary and doesn't support beyond that. I am not sure on BigFloat nor BigRat. The numbers I have in mind are going to be at most 73bits and I couldn't find a better alternative to 'bc' so far.

Replies are listed 'Best First'.
Re^3: bc within perl
by choroba (Cardinal) on Nov 08, 2016 at 10:06 UTC
    > That has a restriction of 64bit binary

    Are you sure?

    perl -Mbigint -wE 'say 12345678912345678912345678912345678912345678912 +3456789123456789 ** 1234'
      So this is bigint and not BigInt? Because when I tried doing the same with BigInt, the data hit the ceiling of xffffffffffffffff.

        Math::BigInt implements the code for arbitrary precision. bigint enables that code transparently wherever it is used.

        > with BigInt, the data hit the ceiling of xffffffffffffffff.

        Show the code. It works for me:

        #!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Math::BigInt; my $x = 'Math::BigInt'->new('123456789' x 5); say $x ** 1234;

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,