NAME

Math::BigInt::Parts - split a Math::BigInt into mantissa and exponent

SYNOPSIS

use Math::BigInt::Parts;

$h = Math::BigFloat->new('6.6260693e-34');   # Planck's constant

# a non-zero, finite mantissa $mant always satisfies 1 <= $mant < 10

($mant, $expo) = $h->fparts();    # $mant = 6.6260693, $expo = -34

# a non-zero, finite mantissa $mant always satisfies 1 <= $mant < 1000
# and the exponent $expo is always a multiple of 3

($mant, $expo) = $h->eparts();    # $mant = 662.60693, $expo = -36

# compare this with the standard parts method, which returns both
# the mantissa and exponent as integers

($mant, $expo) = $h->parts();     # $mant = 66260693, $expo = -41

DESCRIPTION

This module implements the Math::BigInt methods fparts and eparts which are variants of the standard Math::BigInt parts method. fparts and eparts return the mantissa and exponent with the values that are common for floating point numbers in standard notation and in engineering notation, respectively.

METHODS

Behaviour common for both methods

The following applies to both methods, and assumes the methods are called using

($mant, $expo) = $x->fparts ();     # or eparts()
$mant = $x->fparts ();              # or eparts()
Output versus input

For a zero value operand $x, both the mantissa $mant and the exponent $expo is zero. For plus/minus infinity, the mantissa is infinity with the appropriate sign and the exponent is plus infinity. For NaN, both the mantissa and the exponent is NaN. For a non-zero, finite $x, see the appropriate method below.

Regardless of the operand $x and the method, the returned mantissa $mant and the exponent $expo give the value of $x with

$x = $mant * 10 ** $expo;
Context

In list context the mantissa and exponent is returned. In scalar context the mantissa is returned. In void context a warning is given, since there is no point in using any of the methods in this case.

Classes

The mantissa is always a Math::BigFloat object, and the exponent is always a Math::BigInt object.

Behaviour specific for each method

fparts

For a non-zero, finite $x the mantissa $mant always satisfies 1 <= $mant < 10 and the exponent is an integer.

eparts

For a non-zero, finite $x the mantissa $mant always satisfies 1 <= $mant < 1000 and the exponent is an integer which is a multiple of 3.

BUGS

None known.

SEE ALSO

The documentation for Math::BigInt and Math::BigFloat.

AUTHOR

Peter J. Acklam <pjacklam@cpan.org>.

COPYRIGHT AND LICENSE

Copyright (c) 2006 by Peter J. Acklam.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.