Quirrel4.41.0

math.exp

Defined in module "math"
from "math" import exp
pure fastcall exp(x: number): float

Returns e raised to the power of x

Parameters

xnumberthe exponent

Return value

e raised to the power of x, as a float.

Notes

The result is always a float, even when x is an integer: type(exp(0)) is "float".

A large enough x does not throw. It returns infinity, an ordinary float, not an error. A large enough negative x returns 0.0 rather than underflowing to an error.

Example

examples/math/exp.nut
from "math" import exp

println("exp(0) =", exp(0))
println("exp(1) =", exp(1))

// the result is a float even when x is an integer
println("type(exp(0)) =", type(exp(0)))
Output:
exp(0) = 1
exp(1) = 2.71828
type(exp(0)) = float

See also

logReturns the natural logarithm of x
powReturns x raised to the power y
mathmodule index