O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Int Function

Syntax

Int(number)
number

Use: Required

Data Type: Any valid numeric data type

The number to be truncated.

Return Value

Returns a value of the numeric data type passed to it.

Description

Returns the integer portion of a number.

Rules at a Glance

  • The fractional part of number is removed and the resulting integer value returned. Int doesn’t round number to the nearest whole number; for example, Int(100.9) returns 100.

  • If number is negative, Int returns the first negative integer less than or equal to number ; for example, Int(-10.1) returns -11.

Programming Tips and Gotchas

  • Int and Fix work identically with positive numbers. However, for negative numbers, Fix returns the first negative integer greater than number. For example, Int (-10.1) returns -10.

  • Don’t confuse the Int function with CInt. CInt casts the number passed to it as an Integer data type, whereas Int returns the same data type that was passed to it.

See Also

Fix Function

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required