Module : lang.float

Module Overview

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

Functions

abs

IEEE abs operation.

acos

IEEE acos operation

asin

IEEE asin operation

atan

IEEE atan operation

atan2

IEEE atan2(y, x) operation

cbrt

Cube root. IEEE rootn(x, 3)

ceiling

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

cos

IEEE cos operation

cosh

IEEE cosh operation

exp

IEEE exp operation

floor

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

fromBitsInt

Returns the float that is represented in IEEE 64-bit floating point by x. All bit patterns that IEEE defines to be NaNs will all be mapped to the single float NaN value.

fromHexString

Return the float value represented by s. s must follow the syntax of HexFloatingPointLiteral as defined by the Ballerina specification with the following modifications

  • the HexFloatingPointLiteral may have a leading + or - sign
  • NaN is allowed
  • Infinity is allowed with an optional leading + or - sign
fromString

Return the float value represented by s. s must follow the syntax of DecimalFloatingPointNumber as defined by the Ballerina specification with the following modifications

  • the DecimalFloatingPointNumber may have a leading + or - sign
  • NaN is allowed
  • Infinity is allowed with an optional leading + or - sign
  • a FloatingPointTypeSuffix is not allowed This is the inverse of value:toString applied to an float.
isFinite

Tests whether a float is finite. Exactly one of isFinite, isInfinite and IsNaN will be true for any float value

isInfinite

Tests whether a float is infinite. Exactly one of isFinite, isInfinite and IsNaN will be true for any float value

isNaN

Tests whether a float is NaN. Exactly one of isFinite, isInfinite and IsNaN will be true for any float value.

log

Natural logarithm. IEEE log operation

log10

Base 10 log. IEEE log10 operation

max

Maximum of all the arguments. (positive)∞ if no args NaN if any arg is NaN

min

Minimum of all the arguments. ∞ if no args NaN if any arg is NaN

pow

x to the power of y. IEEE pow(x, y)

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 roundToIntegralTiesToEven operation Note that <int>x is the same as <int>x.round()

sin

IEEE sin operation

sinh

IEEE sinh operation

sqrt

IEEE squareRoot operation.

sum

Sum of all the arguments. (positive)0.0 if no args NaN if any arg is NaN

tan

IEEE tan operation

tanh

IEEE tanh operation

toBitsInt

Returns IEEE 64-bit binary floating point format representation of x as an int.

toHexString

Returns a string that represents x as a hexadecimal floating point number. The returned string will comply to the grammar of HexFloatingPointLiteral in the Ballerina spec with the following modifications:

  • it will have a leading - sign if negative
  • positive infinity will be represented by Infinity
  • negative infinity will be represented by -Infinity
  • NaN will be represented by NaN The representation includes 0x for finite numbers.

Constants

PI
E