@Integer (JavaScript)

Truncates a number to an integer.

Defined in

@Functions (JavaScript)

Syntax

@Integer(value:double) : double
Parameter Description
value Number or array of numbers.
Return value Description
double The truncated number or array of numbers.

Usage

A scalar parameter produces a scalar result. An array parameter produces an array result where the result elements correspond to the parameter elements.

This function removes the fractional part of a number, if any, and returns the whole portion. No rounding occurs.

Examples

This example gets 16 random numbers and turns them into integers by moving the decimal point two places to the right and truncating the result.
function p(stuff) {
	print("<<<" + stuff + ">>>");
}

for(var i = 0; i < 16; i++) {
	var r = @Integer(@Random() * 100);
	p(i + " " + r);
}