Stamp_Guy has asked for the wisdom of the Perl Monks concerning the following question:

Hi: Can anyone here give me some examples of how to use the perl library Math::BigFloat? I tried using it, but I was unable to understand how to do it. I am researching various ways perl programmers are able to use huge numbers without running into floating point rounding errors. This is a project for a school assignment. Any help would be appreciated.

Replies are listed 'Best First'.
Re: Math::BigFloat
by Dominus (Parson) on Nov 11, 2000 at 01:27 UTC
    Here's a sample program that uses Math::BigFloat to compute square roots with the Newton-Raphson method. It will compute the square root of the argument you give it, 2 by default.

    use Math::BigFloat; my $N = shift || 2; $g = Math::BigFloat->new($N); for (;;) { $g = ($g + ($N/$g))/2; print $g, "\n"; }

    This is just a demonstration. Normally, a programmer using Math::BigFloat would use the ->fsqrt method to extract a square root.

Re: Math::BigFloat
by Fastolfe (Vicar) on Nov 11, 2000 at 01:18 UTC
    I'm unclear what additional information you're looking for. The Math::BigFloat documentation seems to describe how it works sufficiently to me. Just create a Math::BigFloat item, and use it as you would any numeric scalar.
Re: Math::BigFloat
by Stamp_Guy (Monk) on Nov 11, 2000 at 06:03 UTC
    Thanks for the sample program, Mark. I'm just starting learning perl and have had next to no previous programming experience. I currently am very unclear on how to even use CGI.pm. Are there any places that you think might explain it in laymen's terms?