No matching definitions.

tur/math

stdlib/math.tur

thin wrappers around libm functions (sin, cos, sqrt, ...).

Since: Phase B1

defn

sqrt

(sqrt [x : float] :)

square root of a float (double precision).

xnon-negative float value

The square root of x.

(sqrt 2.0)  ; => 1.41421

Since: Phase B1

defn

fabs

(fabs [x : float] :)

absolute value of a float.

xfloat value

The absolute value of x.

(fabs -3.5)  ; => 3.5

Since: Phase B1

defn

floor

(floor [x : float] :)

largest integer not greater than x.

xfloat value

Floor of x as a float.

(floor 3.7)  ; => 3

Since: Phase B1

defn

ceil

(ceil [x : float] :)

smallest integer not less than x.

xfloat value

Ceiling of x as a float.

(ceil 3.2)  ; => 4

Since: Phase B1

defn

pow

(pow [x : float y : float] :)

x raised to the power y.

xbase value
yexponent

x^y as a float.

(pow 2.0 10.0)  ; => 1024

Since: Phase B1

defn

exp

(exp [x : float] :)

e raised to the power x.

xfloat exponent

e^x.

(exp 1.0)  ; => 2.71828

Since: Phase N2

defn

log

(log [x : float] :)

natural logarithm of a float.

xpositive float value

ln(x).

(log 2.718281828459045)  ; => 1

Since: Phase N2

defn

sin

(sin [x : float] :)

sine of an angle in radians.

xangle in radians

sin(x).

(sin 0.5)  ; => 0.479426

Since: Phase N2

defn

cos

(cos [x : float] :)

cosine of an angle in radians.

xangle in radians

cos(x).

(cos 0.5)  ; => 0.877583

Since: Phase N2

defn

atan2

(atan2 [y : float x : float] :)

principal arc tangent of y/x, using the signs of both arguments

yordinate
xabscissa

The angle in radians in (-pi, pi].

(atan2 1.5 0.0)  ; => 1.5708

Since: Phase N2

defn

int->float

(int->float [n : int] :)

convert an integer to a float via numeric cast.

ninteger value

The integer converted to a double-precision float.

(int->float 42)  ; => 42

Since: Phase B1

defn

float->int

(float->int [x : float] :)

truncate a float to an integer.

xfloat value

The float truncated toward zero as an int.

(float->int 3.9)  ; => 3

Since: Phase B1

defn

printf-float6

(printf-float6 [x : float] :)

print a float to stdout with 6 decimal places followed by a

xfloat value to print

Since: Phase B1