Classic ASP Mathematical Functions

Math functions allow you to perform a variety of operations on number values in your scripts. Here are some of the most commonly used math functions:

Abs:
The Abs function takes a number and returns its absolute value.

intResult = Abs(intNumber)

Exp:
The Exp function takes a numeric value and returns e (the base of natural logarithms) raised to a power.

intResult = Exp(intNumber)

Hex:
The Hex function returns a string value containing the value of an arguement converted to hexadecimal format. If the arguement is a fractional value, it is rounded to the nearest whole number before the function returns the string.

intResult = Hex(intNumber)

Int:
The Int function returns the whole number portion of a numeric arguement. If the arguement is a negative value, it returns the first integer value that is less than or equal to the arguement.

intResult = Int(intNumber)

Fix:
The Fix function returns the whole number portion of a numeric arguement. If the arguement is a negative value, it returns the first integer value that is greater than or equal to the arguement.

intResult = Fix(intNumber)

Rnd:
The Rnd function returns a random number. Switch indicates how the random number will be determined. If switch is a positive number, the next random number in the sequence should be returned. Before calling this function, you should initialize it by using the Randomize statement.

intResult = Rnd[(switch)]

Sgn:
The Sgn function returns a numeric vale representing the sign of a number arguement. It returns 1 if the numeric value is > 0, 0 if = 0, and -1 if < 0.

intResult = Sgn(intNumber)

Sqr:
The Sqr function returns the square root of a numeric arguement.

intResult = Sqr(intNumber)

Sin:
The Sin function returns the sine of an angle.

intResult = Sin(intNumber)

Tan:
The Tan function returns the tangent of an angle.

intResult = Tan(intNumber)

Bookmark

Advertisement