integer(var x)
Integer part of x (after decimals
are cut off).
floor(var x)
Largest integer that is less than or equal to x. The same as integer(x) minus 1 when x is negative. floor() generates an equal distribution of the values, while integer() converts more values to 0.
Parameters:
x -
any var.
Returns:
Integer representation of x.
Speed:
FastRemarks:
The implicit lite-C var->int conversion - f.i. (int)x - uses the floor function (not the integer function) for converting a var to an int.
Examples:
x = integer(2.5); // returns 2
x = integer(0.789); // returns 0
x = integer(-0.789); // returns 0
x = floor(-0.789); // returns -1
// round x to the nearest integer
function round(x) { return floor(x+0.5); }
See also:
fraction
► latest
version online