This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Functions - lang.int

abs

Returns absolute value of an int.

fromHexString

Returns the integer that s represents in hexadecimal.

fromString

Returns the integer that s represents in decimal.

max

Maximum of one or more int values.

min

Minimum of one or more int values

sum

Returns sum of zero or more int values.

toHexString

Returns representation of n as hexdecimal string.

abs

(int n)

returns int

Returns absolute value of an int.

Parameters

  • n int
  • int value to be operated on

  • Return Type

    (int)
  • absolute value of n

fromHexString

(string s)

returns int | error

Returns the integer that s 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 s is not in an allowed format.

Parameters

  • s string
  • hexadecimal string representation of int value

  • Return Type

    (int | error)
  • int value or error

fromString

(string s)

returns int | error

Returns the integer that s represents in decimal. Returns error if s is not the decimal representation of an integer. The first character may be + or -. This is the inverse of value:toString applied to an int.

Parameters

  • s string
  • string representation of a integer value

  • Return Type

    (int | error)
  • int representation of the argument or error

max

(int n, int... ns)

returns int

Maximum of one or more int values.

Parameters

  • n int
  • first int value

  • ns int...
  • other int values

  • Return Type

    (int)
  • maximum value of value of x and all the xs

min

(int n, int... ns)

returns int

Minimum of one or more int values

Parameters

  • n int
  • first int value

  • ns int...
  • other int values

  • Return Type

    (int)
  • minimum value of n and all the ns

sum

(int... ns)

returns int

Returns sum of zero or more int values.

Parameters

  • ns int...
  • int values to sum

  • Return Type

    (int)
  • sum of all the ns; 0 is ns is empty

toHexString

(int n)

returns string

Returns representation of n 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