Skip to content

Instantly share code, notes, and snippets.

@bingos
Created June 22, 2024 18:55
Show Gist options
  • Save bingos/755b19a9a88cc4512946fa64f17e09a9 to your computer and use it in GitHub Desktop.
Save bingos/755b19a9a88cc4512946fa64f17e09a9 to your computer and use it in GitHub Desktop.
You shall go to the dagobah system
cpan@dagobah:~$ /home/cpan/pit/bare-qm/perl-5.36.3/bin/perl -MConfig -MMath::BigFloat -wle'my $data = Math::BigFloat->new(12391239123); my $divisor = Math::BigFloat->new(0.00000001); my ($quotient, $remainder) = $data->bdiv($divisor); print $quotient; print $remainder; print $quotient->is_inf; print Math::BigFloat->VERSION; print $Config{ivsize}; print $Config{nvsize}'
1239123912300000000
0
0
1.999830
4
16
cpan@dagobah:~$
@bingos
Copy link
Author

bingos commented Jun 22, 2024

$ cat /etc/debian_version
12.5
$ uname -a
Linux dagobah 6.1.0-21-686 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) i686 GNU/Linux
$

@karenetheridge
Copy link

karenetheridge commented Jun 22, 2024

Can you try this one too please?

perl -MConfig -MCpanel::JSON::XS -MData::Dumper -wle'
my ($data, $divisor) = @{ Cpanel::JSON::XS->new->allow_bignum->allow_nonref->decode(shift)};
print Dumper([$data, $divisor]);
my $dividend = ref($data) =~ /^Math::Big(?:Int|Float)$/ ? $data->copy : Math::BigFloat->new($data);
my ($quotient, $remainder) = $dividend->copy->bdiv($divisor); print "($quotient, $remainder)";
print Dumper($quotient);
print "overflow? ", $quotient->is_inf;
print Math::BigFloat->VERSION; print "$Config{ivsize}, $Config{nvsize}";
$remainder = $dividend->bmod($divisor);
print Dumper($remainder);
print "remainder: $remainder";
perl -MConfig -MCpanel::JSON::XS -MData::Dumper -wle'
my ($data, $divisor) = @{ Cpanel::JSON::XS->new->allow_bignum->allow_nonref->decode(shift)};
print Dumper([$data, $divisor]);
my $dividend = ref($data) =~ /^Math::Big(?:Int|Float)$/ ? $data->copy : Math::BigFloat->new($data);
my ($quotient, $remainder) = $dividend->copy->bdiv($divisor); print "($quotient, $remainder)";
print Dumper($quotient);
print "overflow? ", $quotient->is_inf;
print Math::BigFloat->VERSION; print "$Config{ivsize}, $Config{nvsize}";
$remainder = $dividend->bmod($divisor);
print Dumper($remainder);
print "remainder: $remainder";
my $inverse = 1/$divisor; print "inverse: $inverse";
my $product = $dividend * $inverse; print "product: $product";
print Dumper($product);
print "product infinite? ", $product->is_inf;
print "product integer? ", $product->is_int;
' "[12391239123,0.00000001]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment