Hello,

My goal is to divide two whole numbers and get the results to a given number of decimals.

$ perl -e 'print 2/3,"\n";'
0.666666666666667
$

#!/usr/bin/perl

use strict;
use warnings;
use Math::BigFloat;
use Data::Dumper;

# from http://search.cpan.org/~tels/Math-BigInt-1.74/lib/Math/BigFloat.pm with my() added,
# my $x = Math::BigFloat->new(11);


my $x = Math::BigFloat->new(2);
Math::BigFloat->precision(5);           # 5 digits max
my $y = $x->copy()->bdiv(3);               # will give 0.66666

# $ perl -e 'print 2/3,"\n";'
# 0.666666666666667
# $

print Dumper $y;

The docs says "will give 0.66666" so how does one get $y to give you that?

That is what I can't seem to find and the Dump of $y doesn't seem to contain any part of the answer...

TIA




-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to