Decimal
Library of functions for the decimal type.
Functions
From
Builds a decimal from a number or string.
Syntax:
Decimal.From(value: number or string)
Parameters
value
: The value to convert to decimal.
Returns
decimal
: The decimal representation of the value.
Example:
Decimal.From(1)
// Result:
// 1.0
Decimal.From("1")
// Result:
// 1.0
Decimal.From(1.5)
// Result:
// 1.5
Round
Rounds a decimal to the specified number of decimal places.
Syntax:
Decimal.Round(value: decimal, decimal cases: int)
Parameters
-
value
: The value to be round. -
decimal cases
: Number of decimal places to round to.
Returns
decimal
: The rounded decimal.
Example:
Round(2.1234, 2)
// Result:
// 2.12
Round(2.1234, 3)
// Result:
// 2.123