Module : lang.decimal

Module Overview

This module provides lang library operations on decimal values defined by the language specification 2019R2.

Functions

abs

IEEE abs operation.

ceiling

Smallest (closest to -∞) floating point value not less than x that is a mathematical integer

floor

Largest (closest to +∞) floating point value not greater than x that is a mathematical integer.

fromString

Return the decimal value represented by s. 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 value:toString applied to an decimal.
max

Maximum of all the arguments.

min

Minimum of all the arguments.

round

Floating point value that is a mathematical integer and closest to x. If there are two such integers, choose the one that is even (this is the round-to-nearest rounding mode, which is the default for IEEE and for Ballerina). Same as Java Math.rint method Same as .NET Math.Round method IEEE 754 roundToIntegralTiesToEven operation Note that <int>x is the same as <int>x.round()

sum

Sum of all the arguments. 0 if no args.