expm1() And log1p()

By Alexandre Daubois

../_images/expm1.png

In PHP, expm1() computes exp(x) - 1.

log1p() computes log(1 + x).

“Why not just write exp($x) - 1” you may ask…

Because when x is close to 0, floating point eats your precision alive. Think about it if you deal with finance!

These two functions exist solely to save your math from IEEE 754.

See Also

PHP Features