VBS tutorial: functions int, fix functions

Time:2021-10-11

Int, fix functions

Returns the integer part of a number.

Int(number)

Fix(number)

numberThe parameter can be any valid numeric expression. IfnumberReturns if the parameter contains nullNull

explain

IntandFixAll functions are deletednumberParameter and returns the result as an integer.

IntandFixThe difference between functions is ifnumberWhen the parameter is negative,IntFunction returns less than or equal tonumberThe first negative integer of, andFixFunction returns greater than or equal tonumberThe first negative integer of the parameter. For example,IntConvert – 8.4 to – 9, andFixThe function converts – 8.4 to – 8.

Fix (number) is equivalent to:

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

The following example illustratesIntandFixHow the function returns the integer part of a number:

Mynumber = int (99.8) 'returns 99. Mynumber = fix (99.2) 'returns 99. Mynumber = int (- 99.8) 'returns - 100. Mynumber = fix (- 99.8) 'returns - 99. Mynumber = int (- 99.2) 'returns - 100. Mynumber = fix (- 99.2) 'returns - 99.