# Functions

 abs IReturns the IEEE absolute value of a decimal value. ceiling IRounds a decimal up to the closest integral value. floor IRounds a decimal down to the closest integral value. fromString IReturns the decimal value represented by a string. max IReturns the maximum of one or more decimal values. min IReturns the minimum of one or more decimal values. round IRounds a decimal to the closest integral value. sum IReturns the sum of zero or more decimal values.

## abs

``function abs(decimal x) returns decimal``
Isolated Function

Returns the IEEE absolute value of a decimal value.

### Parameters

• x
• decimal value to operate on

### Return Type

(decimal)

absolute value of parameter `x`

## ceiling

``function ceiling(decimal x) returns decimal``
Isolated Function

Rounds a decimal up to the closest integral value.

### Parameters

• x
• decimal value to operate on

### Return Type

(decimal)

smallest (closest to -∞) decimal value not less than parameter `x` that is a mathematical integer

## floor

``function floor(decimal x) returns decimal``
Isolated Function

Rounds a decimal down to the closest integral value.

### Parameters

• x
• decimal value to operate on

### Return Type

(decimal)

largest (closest to +∞) decimal value not greater than parameter `x` that is a mathematical integer.

## fromString

``function fromString(string s) returns decimal | error``
Isolated Function

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 representation of a decimal

### Return Type

()

decimal representation of the argument or error

## max

``function max(decimal x, decimal... xs) returns decimal``
Isolated Function

Returns the maximum of one or more decimal values.

### Parameters

• x
• first decimal value

### Return Type

(decimal)

maximum value of parameter `x` and all the parameter `xs`

## min

``function min(decimal x, decimal... xs) returns decimal``
Isolated Function

Returns the minimum of one or more decimal values.

### Parameters

• x
• first decimal value

### Return Type

(decimal)

minimum value of parameter `x` and all the parameter `xs`.

## round

``function round(decimal x) returns decimal``
Isolated Function

Rounds a decimal to the closest integral value.

Returns the decimal value that is a mathematical integer and closest to parameter `x`. If there are two such values, 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()`

### Parameters

• x
• decimal value to operate on

### Return Type

(decimal)

closest decimal value to parameter `x` that is a mathematical integer

## sum

``function sum(decimal... xs) returns decimal``
Isolated Function

Returns the sum of zero or more decimal values.

### Parameters

• xs decimal...
• decimal values to sum

### Return Type

(decimal)

sum of all the parameter `xs`; 0 if parameter `xs` is empty