VBScript » Functions » Int

Version: 1.0

Syntax:
Int(Number)

The Int function converts a decimal number (floating-point) to an integer number (fix-point).

There is one major difference between Int and Fix. Int rounds negative numbers down. Fix rounds negative numbers up.

Examples

Code:
<% =Int(123.456) %>
Output:
123
Explanation:

Positive numbers are not rounded up. The decimal point and all digits to the right are effectively chopped off.

Language(s): VBScript
Code:
<% =Int(123.899) %>
Output:
123
Language(s): VBScript
Code:
<% =Int(-123.456) %>
Output:
-124
Explanation:

Negative numbers are rounded down (towards more negative).

Language(s): VBScript

See Also: