Functions
abs | I Returns the IEEE absolute value of a decimal value. |
ceiling | I Rounds a decimal up to the closest integral value. |
floor | I Rounds a decimal down to the closest integral value. |
fromString | I Returns the decimal value represented by a string. |
max | I Returns the maximum of one or more decimal values. |
min | I Returns the minimum of one or more decimal values. |
quantize | I IEEE quantize operation. |
round | I Round a decimal to a specified number of digits. |
sum | I Returns the sum of zero or more decimal values. |
abs
Returns the IEEE absolute value of a decimal value.
Parameters
- x decimal
decimal value to operate on
ceiling
Rounds a decimal up to the closest integral value.
Parameters
- x decimal
decimal value to operate on
Return Type
(decimal)smallest (closest to -∞) decimal value not less than parameter x
that is a mathematical integer
floor
Rounds a decimal down to the closest integral value.
Parameters
- x decimal
decimal value to operate on
Return Type
(decimal)largest (closest to +∞) decimal value not greater than parameter x
that is a mathematical integer.
fromString
Returns the decimal value represented by a string.
s
must follow the syntax of DecimalFloatingPointNumber as defined by the Ballerina specification
with the following modifications
- the DecimalFloatingPointLiteral may have a leading
+
or-
sign - a FloatingPointTypeSuffix is not allowed
This is the inverse of function value:toString
applied to an decimal
.
Parameters
- s string
string representation of a decimal
max
Returns the maximum of one or more decimal values.
min
Returns the minimum of one or more decimal values.
quantize
IEEE quantize operation.
round
Round a decimal to a specified number of digits.
Returns the decimal value that has an exponent of -fractionDigits
and is closest to x
.
If there are two such values, returns the one whose final digit is even
(this is the round-to-nearest rounding mode, which is the default for IEEE
and for Ballerina).
A value of fractionDigits
greater than 0 thus corresponds to the number of digits after the decimal
point being fractionDigits
; a value of 0 for fractionDigits
rounds to an integer.
Note that IEEE 754 roundToIntegralTiesToEven operation differs from round
with fractionDigits
as 0, in that
roundToIntegralTiesToEven will return a value with a positive exponent when the operand has a positive exponent.
Note that <int>x
is the same as <int>x.round(0)
.
Parameters
- x decimal
decimal value to operate on
- fractionDigits int (default 0)
the number of digits after the decimal point
Return Type
(decimal)closest decimal value to x
that is an integral multiple of 10 raised to the power of -fractionDigits