当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > VBS教程:函数-Int、Fix 函数

VBScript
VBS教程:方法-Skip 方法
VBS教程:方法-Remove 方法
VBS教程:方法-ReadLine 方法
VBS教程:方法-ReadAll 方法
VBS教程:方法-Read 方法
VBS教程:方法-OpenTextFile 方法
VBS教程:方法-OpenAsTextStream 方法
VBS教程:方法-MoveFolder 方法
VBS教程:方法-MoveFile 方法
VBS教程:方法-Move 方法
VBS教程:方法-Keys 方法
VBS教程:方法-Items 方法
VBS教程:方法-GetTempName 方法
VBS教程:方法-GetSpecialFolder 方法
VBS教程:方法-GetParentFolderName 方法
VBS教程:方法-GetFolder 方法
VBS教程:方法-GetFileName 方法
VBS教程:方法-GetFile 方法
VBS教程:方法-GetExtensionName 方法
VBS教程:方法-GetDriveName 方法

VBScript 中的 VBS教程:函数-Int、Fix 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 121 ::
收藏到网摘: n/a

Int、Fix 函数

返回数字的整数部分。

Int(number)

Fix(number)

number 参数可以是任意有效的数值表达式。如果 number 参数包含 Null,则返回 Null

说明

IntFix 函数都删除 number 参数的小数部分并返回以整数表示的结果。

IntFix 函数的区别在于如果 number 参数为负数时,Int 函数返回小于或等于 number 的第一个负整数,而 Fix 函数返回大于或等于 number 参数的第一个负整数。例如,Int 将 -8.4 转换为 -9,而 Fix 函数将 -8.4 转换为 -8。

Fix(number) 等同于:

Sgn(number) * Int(Abs(number))

下面的示例说明 IntFix 函数如何返回数字的整数部分:

MyNumber = Int(99.8) ' 返回 99MyNumber = Fix(99.2) ' 返回 99MyNumber = Int(-99.8) ' 返回 -100MyNumber = Fix(-99.8) ' 返回-99MyNumber = Int(-99.2) ' 返回 -100MyNumber = Fix(-99.2) ' 返回 -99