lang.int
ballerina/lang.int
Module overview
The lang.int
module corresponds to the int
basic type.
Functions
abs
Returns the absolute value of an int value.
Parameters
- n int - int value to be operated on
Return Type
- int - absolute value of parameter
n
fromHexString
Returns the integer that a string value represents in hexadecimal.
Both uppercase A-F and lowercase a-f are allowed.
It may start with an optional +
or -
sign.
No 0x
or 0X
prefix is allowed.
Returns an error if the parameter s
is not in an allowed format.
Parameters
- s string - hexadecimal string representation of int value
fromString
Returns the integer of a string that represents in decimal.
Returns error if parameter s
is not the decimal representation of an integer.
The first character may be +
or -
.
This is the inverse of function value:toString
applied to an int
.
Parameters
- s string - string representation of a integer value
max
Returns the maximum of one or more int values.
Return Type
- int - maximum value of value of parameter
n
and all of parameterns
min
Returns the minimum of one or more int values.
Return Type
- int - minimum value of parameter
n
and all of parameterns
sum
Returns sum of zero or more int values.
Parameters
- ns int... - int values to sum
Return Type
- int - sum of all of parameter
ns
; 0 if parameterns
is empty
toHexString
Returns representation of an integer as hexdecimal string.
There is no 0x
prefix. Lowercase letters a-f are used.
Negative numbers will have a -
prefix. No sign for
non-negative numbers.
Parameters
- n int - int value
Return Type
- string - hexadecimal string representation of int value
Constants
lang.int: MAX_VALUE
Maximum value of type int
.
lang.int: MIN_VALUE
Minimum value of type int
.
lang.int: SIGNED16_MAX_VALUE
Maximum value of type Signed16
.
lang.int: SIGNED16_MIN_VALUE
Minimum value of type Signed16
.
lang.int: SIGNED32_MAX_VALUE
Maximum value of type Signed32
.
lang.int: SIGNED32_MIN_VALUE
Minimum value of type Signed32
.
lang.int: SIGNED8_MAX_VALUE
Maximum value of type Signed8
.
lang.int: SIGNED8_MIN_VALUE
Minimum value of type Signed8
.
lang.int: UNSIGNED16_MAX_VALUE
Maximum value of type Unsigned16
.
lang.int: UNSIGNED32_MAX_VALUE
Maximum value of type Unsigned32
.
lang.int: UNSIGNED8_MAX_VALUE
Maximum value of type Unsigned8
.
Types
lang.int: Signed16
Built-in subtype that allows non-negative integers that can be represented in 16 bits using two's complement. This allows an int between -2^15 and 2^15 - 1 inclusive, i.e., between -32,768 and 32,767 inclusive.
lang.int: Signed32
Built-in subtype that allows signed integers that can be represented in 32 bits using two's complement. This allows an int between -2^31 and 2^31 - 1 inclusive, i.e., between -2,147,483,648 and 2,147,483,647 inclusive.
lang.int: Signed8
Built-in subtype that allows non-negative integers that can be represented in 8 bits using two's complement. This allows an int between -2^7 and 2^7 - 1 inclusive, i.e., between -128 and 127 inclusive.
lang.int: Unsigned16
Built-in subtype that allows non-negative integers that can be represented in 16 bits. This allows an int between 0 and 2^16 - 1 inclusive, i.e., between 0 and 65,535 inclusive.
lang.int: Unsigned32
Built-in subtype that allows non-negative integers that can be represented in 32 bits. This allows an int between 0 and 2^32 - 1 inclusive, i.e., between 0 and 4,294,967,295 inclusive.
lang.int: Unsigned8
Built-in subtype that allows non-negative integers that can be represented in 8 bits.
This allows an int between 0 and 2^8 - 1 inclusive,
i.e., between 0 and 255 inclusive.
This is the same as byte
.