Functions Index :: C :: CFloat

[<< up one level]

Module:

base :: conversion

Definition:

CFloat(val "x", bool "force")

Description:

Converts any variable to a float type variable. The conversion follows the rules of the table below:

Type of xResult
clip0.0
floatx unchanged
intFloat(x)
boolif x == true 1.0, else 0.0
stringFloat(Value(x))

Arguments:

"x": The variable to convert.

"force" (Optional, defaults to false): If true and x is an undefined variable (ie Defined(x) returns false) then the function returns 0.0. Else the function propagates the undefined variable to the caller, ie it returns an undefined value.

Examples:

i = 12

b = true

s = "2.1"

f1 = CFloat(i) # f1 == 12.0

f2 = CFloat(b) # f2 == 1.0

f3 = CFloat(s) # f3 == 2.1

 

[<< top]