simple calculator

A. R. Vener salt at aero-vision.com
Fri Feb 27 01:59:08 UTC 2004


Here is a quick and  dirty multi precision calculator
which I just knocked off in perl.
It will evaluate and print any reasonable  math string including
perls built in math functions such as  sqrt, log, sin cos  and so forth.

You can change precision by putting a entering a p followed by the number of
decimal positions  you want displayed. I default to 2 for money related 
calculations.
Just be sure yyour version of perl is correctly pointed to by the first line.

Have fun.

Rudy


-----------------cut here-----------------------
#!//usr/bin/perl


$prec=2;
while (<STDIN>)
{
chomp $_;
/^q/ and exit;
/^p/ and s/^p *// and $prec = $_ and next;
$rv= eval "$_";
printf ("%.${prec}f\n", $rv);
}





More information about the Blinux-list mailing list