Plankton has asked for the wisdom of the Perl Monks concerning the following question:
Friends,
I have never used Math::BigInt before. So I came up with an excuse to write a script that would use it. I wanted to write a simple script that would tell me how many CDs would be needed to hold X Gigabytes of data. Here's the script ...
When I run this I get the output of:#!/usr/bin/perl -w use strict; use Math::BigInt; #BigInt KiloByte Unit my $KB = Math::BigInt ( "1024" ); #BigInt MegaByte Unit my $MB = Math::BigInt ( $KB->bmul( $KB ) ); #BigInt GigaByte Unit my $GB = Math::BigInt ( $MB->bmul( $KB ) ); my $arg1 = Math::BigInt->new( shift ); # arg1 is in GBs my $GBarg1 = Math::BigInt->new( $arg1->bmul( $GB ) ); my $arg2 = Math::BigInt->new( shift ); # arg2 is in MBs my $MBarg2 = Math::BigInt->new( $arg2->bmul( $MB ) ); # why rc is 0? my $rc = $GBarg1->bdiv( $MBarg2 ); print "rc is [$rc]\n";
What am I doing wrong here?$ ./whomany.pl 2 675 rc is [0]
Thanks
update: Fixed typo (missing my $arg2) pointed out by Paladin.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Math::BigInt Newbee question.
by Paladin (Vicar) on Jan 27, 2005 at 16:57 UTC | |
by ikegami (Patriarch) on Jan 27, 2005 at 17:20 UTC | |
|
Re: Math::BigInt Newbee question.
by ikegami (Patriarch) on Jan 27, 2005 at 17:23 UTC | |
|
Re: Math::BigInt Newbee question.
by hv (Prior) on Jan 28, 2005 at 12:10 UTC |