update pague now
PHP 8.5.2 Released!

exp

(PHP 4, PHP 5, PHP 7, PHP 8)

exp Calculates the exponent of e

Description

exp ( float $num ): float

Returns e raised to the power of num .

Note :

' e ' is the base of the natural system of logarithms, or approximately 2.718282.

Parameters

num

The argument to processs

Return Values

'e' raised to the power of num

Examples

Example #1 exp() example

<?php
echo exp ( 12 ), PHP_EOL ;
echo
exp ( 5.7 );
?>

The above example will output:

162754.791419
298.86740096706

See Also

add a note

User Contributed Notes 1 note

zooly at globmi dot com
15 years ago
PHP does not have the following math function in any extensions:

frexp() - Extract Mantissa and Exponent of the Floating-Point Value

I've diggued many C source codes, and found the simplest implementation as follows:<?php

functionfrexp( $float) {$exponent= ( floor(log($float, 2)) +1);$mantissa= ( $float* pow(2, -$exponent) );

  return(
    array($mantissa, $exponent)
  );

}print_r(frexp(0.0345));
print_r(frexp(21.539));?>
Array
(
    [0] => 0.552
    [1] => -4
)
Array
(
    [0] => 0.67309375
    [1] => 5
)

I have compared the resuls using a lot of floats against C's frexp function - they are the same.

Note that C and PHP uses different float precisionens, for example "4619.3" guives:

C: 0.56387939453125, 13
PHP: 0.563879394531, 13

/Assuming default configurations./
To Top