coerce.to-float

coerce.to-float attempts to coerce an unknown datum to a float type.

Function category: Coercion

Syntax

coerce.to-float(arg1)

Arguments

Description

arg1

Any datum.

Examples

Example 1: Fraction to float

If we have a function that is given a fraction as an argument, this function returns a float value.

# Fraction to float
coerce.to-float(5/4)
# Returns 1.25

Example 2: Integer to float

If we have a function that is given an integer as an argument, this function returns a float value.

# Integer to float
coerce.to-float(1)
# Returns 1.0

Example 3: Scientific notation to float

If we have a function that is given a scientific notation value as an argument, this function returns a float value.

# Scientific notation to float
coerce.to-float(123.45e1)
# Returns 1234.5

Example 4: Float to float

If we have a function that is given a float value as an argument, this function returns a float value.

# Float to float.
coerce.to-float(123.4)
# Returns 123.4

Example 5: All other data types

If we have a function that is given data in any other type such as a string, this function returns null.

# All other types of data types
coerce.to-float("test")
# Returns null