float
Syntax
float([X])
Details
Converts the type of input data to FLOAT.
Parameters
X (optional): Any data type, and can be in any data form.
Returns
Data of the FLOAT type, and the data form is the same as X。
Examples
Create a FLOAT variable with a default value of null.
x=float()
x // Output: null
typestr x // Output: 'FLOAT'
Convert a string that indicates a number.
x=float("123")
x // Outout: 123
typestr x // Output: 'FLOAT'
Convert a boolean value.
x=float([true, false])
x // Output: [1, 0]
typestr x // Output: 'FAST FLOAT VECTOR'
Convert data of the DOUBLE type.
x=123456789.1234567 // 16 digits
typestr x // Output: 'DOUBLE'
y=float(x)
y // Output: 123,456,792 (FLOAT accepts 9 digits at most)
typestr y // Output: 'FLOAT'
Create variables with positive and negative infinity values.
// Create a variable with a positive infinity value
posInf = float("inf")
posInf // Output: ∞
typestr posInf // Output: 'FLOAT'
posInf > 1000000000 // Output: true
// Create a variable with a negative infinity value
negInf = float("-inf")
negInf // Output: -∞
typestr negInf // Output: 'FLOAT'
negInf < NULL // Output: true
