Number functions

Different languages have different syntax for getting substrings and pushing element to array. Gutt provides solid common functions for working with strings, numbers and maps.

All this functions is just a declaration. In real life stringifiers and platforms may return different values. I hope there is nothing critical, but i have to warning you.

num_int#

num_int($number)

Converts string or float to int. The fractional part will be just dropped

Parameters

$number

the number to use

Examples

{num_int(11/3)} <!-- 3 -->{num_int('123.456')} <!-- 123 -->

num_pow#

num_pow($base, $exp)

Exponential expression

Parameters

$base

the base to use

$exp

the exponent

Examples

{num_pow(2, 3)} <!-- 8 -->{num_pow(4, 5)} <!-- 1024 -->

num_abs#

num_abs($number)

Absolute value

Parameters

$number

the number to use

Examples

{num_abs(-2)} <!-- 2 -->{num_abs(4)} <!-- 4 -->

num_acos#

num_acos($number)

Arc cosine

Parameters

$number

the number to use

Examples

{num_acos(0.5)} <!-- 1.0471975511965979 -->

num_asin#

num_asin($number)

Arc sine

Parameters

$number

the number to use

Examples

{num_asin(0.5)} <!-- 0.5235987755982989 -->

num_atan#

num_atan($number)

Arc tangent

Parameters

$number

the number to use

Examples

{num_atan(0.5)} <!-- 0.4636476090008061 -->

num_cos#

num_cos($number)

Cosine

Parameters

$number

the number to use

Examples

{num_cos(0.5)} <!-- 0.8775825618903728 -->

num_sin#

num_sin($number)

Sine

Parameters

$number

the number to use

Examples

{num_sin(0.5)} <!-- 0.479425538604203 -->

num_tan#

num_tan($number)

Tangent

Parameters

$number

the number to use

Examples

{num_tan(0.5)} <!-- 0.5463024898437905 -->

num_round#

num_round($number)

Returns rounded to integer

Parameters

$number

the number to use

Examples

{num_round(2.5)} <!-- 3 -->{num_round(2.6)} <!-- 3 -->{num_round(2.4)} <!-- 2 -->{num_round(-2.5)} <!-- -2 -->{num_round(-2.6)} <!-- -3 -->{num_round(-2.4)} <!-- -2 -->

num_sqrt#

num_sqrt($number)

Square root

Parameters

$number

the number to use

Examples

{num_sqrt(16)} <!-- 4 -->

num_rand#

num_rand($number)

Generate a random number in range from 0 to 1

Examples

{num_rand()} <!-- 0.4711243341951896 -->