Functions Index :: C :: CFloat
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 x | Result |
---|---|
clip | 0.0 |
float | x unchanged |
int | Float(x) |
bool | if x == true 1.0, else 0.0 |
string | Float(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