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

When given a fraction, coerce.to-float will coerce the value of the fraction to its decimal value.

coerce.to-float(5/4) = 1.25

Example 2: Integer to float

When given an integer, coerce.to-float will return its value as a float.

coerce.to-float(1) = 1.0

Example 3: Scientific notion to float

When given a number in scientific notation, coerce.to-float will coerce it to its decimal value.

coerce.to-float(123.45e1) = 1234.5

Example 4: Float to float

When given a float, coerce.to-float will return a float.

coerce.to-float(123.4) = 123.4

Example 5: All other types of data

For all other data, coerce.to-float will return null

coerce.to-float("test") = null

Notes