# every-thing.net
Big Exponent Calculator using Perl
# Don Ritter 2003
use Math::BigInt; #BigInt module required
# calculation is every-object (e) = 109^(6.55 x 10^106) # 1: set variable values and output file name $item = objects; #<<<<<<<<enter name of calculation here $b = 109; # (v) <<<<<<<<enter value of base number to be used here $bd = 1; # <<<<<<<<enter value of base multiplier here (if base is 1/10 of actual enter 10) $e = 655000; # (c) <<<<<<<<enter value of exponent to be used here $ed = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000; # <<<<<<<<enter value of base divisor here (if base is 1/10 of actual enter 10) $outfilefolder = 'mycomputer:folder:'; # <<<<<<<<enter output folder name here
$outfile = $outfilefolder.numbers_.$item;
$p = 100 /( $bd * $ed); #percentage of final calculation being determined
$r = $bd * $ed; #ratio of number being calculated
# 2: Validate output
file
if ( -e $outfile) {
print STDERR "Output file $outfile exists!\n";
until ($ans eq 'r' || $ans eq 'a' || $ans eq 'e' ) {
print STDERR "replace, append, or exit? ";
$ans = getc(STDIN);
}
if ($ans eq 'e') {exit}
}
if ($ans eq 'a') {$mode='>>'}
else {$mode='>'}
open(OUTPUT,"$mode$outfile") ||
die "Can't output $outfile $!";
# 3: Do calculation
print "big exponent calculation in process\n";
$start = time();
print $item;
print OUTPUT "\n";
print "\n";
print OUTPUT "$b to power of $e = ";
print OUTPUT Math::BigInt->new($b)**$e;
print OUTPUT " possible $item\n";
print OUTPUT "\n";
print "\n";
print "base is divided by $bd\n";
print "exponent is divided by $ed\n";
print "number is $p % of final calculation\n";
print "$b to power of $e\n";
print OUTPUT "base is divided by $bd\n";
print OUTPUT "exponent is divided by $ed\n";
print OUTPUT "number is $p % of final calculation\n";
print OUTPUT "$b to power of $e\n";
$fin = time();
print OUTPUT "\n";
print OUTPUT 'processing time used = ',$fin-$start,' seconds',"\n";
print OUTPUT 'processing time used = ',($fin-$start)/60,' minutes',"\n";
print OUTPUT 'processing time used = ',($fin-$start)/3600,' hours',"\n";
print OUTPUT 'processing time required for final calculation = ',$r*($fin-$start)/3600,'
hours',"\n";
print OUTPUT 'processing time required for final calculation = ',$r*($fin-$start)/31556926.08
,' years',"\n";
print 'processing time used = ',$fin-$start,' seconds',"\n";
print 'processing time used = ',($fin-$start)/60,' minutes',"\n";
print 'processing time used = ',($fin-$start)/3600,' hours',"\n";
print 'processing time required for final calculation = ',$r*($fin-$start)/3600,'
hours',"\n";
print 'processing time required for final calculation = ',$r*($fin-$start)/31556926.08
,' years',"\n";
print "big exponent calculation in $outfile\n";
# 4: Done
close OUTPUT;
exit;
|