Functions Index :: C :: CInt
Module:
base :: conversion
Definition:
CInt(val "x", bool "force")
Description:
Converts any variable to an int type variable. The conversion follows the rules of the table below:
Type of x | Result |
---|---|
clip | 0 |
float | Int(x) |
int | x unchanged |
bool | if x == true 1, else 0 |
string | Int(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:
f = 12.62
b = false
s = "2.1"
i1 = CInt(f) # i1 == 12
i2 = CInt(b) # i2 == 0
i3 = CInt(s) # i3 == 2