Quirrel4.41.0

math.tan

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

Returns the tangent of x (in radians)

Parameters

xnumberangle in radians

Return value

The tangent of x, always as a float.

Notes

Near an odd multiple of PI/2 the tangent has a vertical asymptote. Quirrel does not throw there; it returns whatever the underlying C tan computes for the (inexact) argument, typically a very large finite number rather than an error. That magnitude depends on the float precision the build uses and is not the same across platforms, so do not print or compare it.

Example

examples/math/tan.nut
from "math" import tan, PI

println("tan(0) =", tan(0))
println("tan(PI/4) =", tan(PI/4))
println("tan(-PI/4) =", tan(-PI/4))
Output:
tan(0) = 0
tan(PI/4) = 1
tan(-PI/4) = -1

See also

sinReturns the sine of x (in radians)
cosReturns the cosine of x (in radians)
atanReturns the arctangent of x
PIThe ratio of a circle's circumference to its diameter, for converting between radians and degrees and for angle math in general.
mathmodule index