Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I came up with the following code recently as an experiment:


    use strict;
    use Math::BigFloat;
    use Time::HiRes;

    my $x = Math::BigFloat->new(my $str);
    $x->accuracy(100);
    my $start = (times)[0];
    $x=48*atan2(1,18)+32*atan2(1,57)-20*atan2(1,239);
    my $end = (times)[0];
    my $elapsed = $end-$start;
    printf "%.100f".$x."\n";
    printf "that took %.100f CPU seconds.\n",$elapsed;

    My source for the calculation of pi is a formula attributed to Gauss in the 1977 Van Nostrand Reinhold "Encyclopedia of Mathematics." I was interested in seeing how fast this would run on different machines that I have.