7.2.42 Math::BigFloat - Arbitrary-Length, Floating-Point Math Packageuse Math::BigFloat; $f = Math::BigFloat->new($string); # This module allows you to use floating-point numbers of arbitrary length. For example: $float = new Math::BigFloat "2.123123123123123123123123123123123";
Number strings ( $f = Math::BigFloat->new("-20.0 0732"); $g = $f->fmul("-20.00732");
The return value
If max($div_scale, length(dividend)+length(divisor)) A similar default scale value is computed for square roots. When you use this module, Perl's basic math operations are overloaded with routines from Math::BigFloat. Therefore, you don't have to employ the methods shown above to multiply, divide, and so on. You can rely instead on the usual operators. Given this code: $f = Math::BigFloat->new("20.00732"); $g = Math::BigFloat->new("1.7");
the following six lines all yield the corresponding values for $h = 20.00732 * 1.7; # 34.012444 (ordinary math--$h is not an object) $h = $f * $g; # "34.012444" ($h is now a BigFloat object) $h = $f * 1.7; # "34.012444" ($h is now a BigFloat object) $h = 20.00732 * $g; # "34.012444" ($h is now a BigFloat object) $h = $f->fmul($g); # "+34012444E-6" ($h is now a BigFloat object) $h = $f->fmul(1.7); # "+34012444E-6" ($h is now a BigFloat object) |
|