Home   |   Contact Us   |   Site Map

 

 

 

  BigFloat.pm Perldoc

 


NAME

Math::BigFloat - Arbitrary length float math package


SYNOPSIS

use Math::BigFloat; $f = Math::BigFloat->new($string);

$f->fadd(NSTR) return NSTR addition $f->fsub(NSTR) return NSTR subtraction $f->fmul(NSTR) return NSTR multiplication $f->fdiv(NSTR[,SCALE]) returns NSTR division to SCALE places $f->fmod(NSTR) returns NSTR modular remainder $f->fneg() return NSTR negation $f->fabs() return NSTR absolute value $f->fcmp(NSTR) return CODE compare undef,<0,=0,>0 $f->fround(SCALE) return NSTR round to SCALE digits $f->ffround(SCALE) return NSTR round at SCALEth place $f->fnorm() return (NSTR) normalize $f->fsqrt([SCALE]) return NSTR sqrt to SCALE places


DESCRIPTION

All basic math operations are overloaded if you declare your big floats as

$float = new Math::BigFloat "2.123123123123123123123123123123123";

number format
canonical strings have the form /[+-]\d+E[+-]\d+/ . Input values can have embedded whitespace.

Error returns 'NaN'
An input parameter was ``Not a Number'' or divide by zero or sqrt of negative number.

Division is computed to
max($Math::BigFloat::div_scale,length(dividend)+length(divisor)) digits by default. Also used for default sqrt scale.

Rounding is performed
according to the value of $Math::BigFloat::rnd_mode:

trunc truncate the value zero round towards 0 +inf round towards +infinity (round up) -inf round towards -infinity (round down) even round to the nearest, .5 to the even digit odd round to the nearest, .5 to the odd digit

The default is even rounding.


BUGS

The current version of this module is a preliminary version of the real thing that is currently (as of perl5.002) under development.

The printf subroutine does not use the value of $Math::BigFloat::rnd_mode when rounding values for printing. Consequently, the way to print rounded values is to specify the number of digits both as an argument to ffround and in the %f printf string, as follows:

printf "%.3f\n", $bigfloat->ffround(-3);


AUTHOR

Mark Biggar Patches by John Peacock Apr 2001 =cut



 

Browse our Perldoc FAQs:

Perldoc Home

Perldoc Site Map


Previous Topics

autouse.pm Perldoc

Base64.pm Perldoc

Basename.pm Perldoc

base.pm Perldoc

Base.pm Perldoc

Basic.pm Perldoc

Bblock.pm Perldoc

Benchmark.pm Perldoc


Next Topics

BigInt.pm Perldoc

blib.pm Perldoc

B.pm Perldoc

BuildDOM.pm Perldoc

Builder.pm Perldoc

Bytecode.pm Perldoc

ByteLoader.pm Perldoc

bytes.pm Perldoc


Website Spotlight

Domain Hosting with the Leader in Innovative and Comprehensive Web Hosting Solutions, Globalnet GNP.

Reliable Domain Hosting

 

Click here to increase your web traffic insantly!


 Copyright © 1999-2005 Globalnet Promotions, LLC.   |   TheServerRoom.org Home    |   Sitemap    |   RSS News Feeds