Functions Index :: C :: CInt

[<< up one level]

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 xResult
clip0
floatInt(x)
intx unchanged
boolif x == true 1, else 0
stringInt(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

 

[<< top]