Post

Decimal Lang Library

ballerina\lang.decimal Lang Library provides utility functions for decimal type.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import ballerina/io;

public function main() {

    decimal x = 5.5;
    decimal y = -10.0;

    decimal maxVal = decimal:max(x, y);
    decimal minVal = decimal:min(x, y);
    decimal absY = y.abs();
    decimal roundVal = x.round();

    string output = string `ballerina/lang.decimal Functions:
    x: ${x}
    y: ${y}
    max(x, y): ${maxVal}
    min(x, y): ${minVal}
    abs(y): ${absY}
    round(x): ${roundVal}
    `;
    io:println(output);
}
ballerina/lang.decimal Functions:
    x: 5.5
    y: -10.0
    max(x, y): 5.5
    min(x, y): -10.0
    abs(y): 10.0
    round(x): 6
    
 bal version
Ballerina 2201.6.0 (Swan Lake Update 6)
// Partial Code. Change View  to see full code.
public function main() {
    decimal x = 5.5;
    decimal y = -10.0;

    decimal maxVal = decimal:max(x, y);
    decimal minVal = decimal:min(x, y);
    decimal absY = y.abs();
    decimal roundVal = x.round();
}
// Highlights Only. Change View  to see full code.
decimal x = 5.5;
decimal y = -10.0;

decimal maxVal = decimal:max(x, y);
decimal minVal = decimal:min(x, y);
decimal absY = y.abs();
decimal roundVal = x.round();

Decimal Lang Library

 June 1, 2023

Table of Content

Key Words

Decimal Lang Library
 June 1, 2023

Table of Content

Key Words


Navigation

Site Settings

Site Theme

Source Code Density