Mathematical Functions in asp.net

Popular mathematical functions are summarized in the following table. Note that certain functions do not require the Math. prefix.

Function Use
Math.Abs() Returns the absolute value.

Math.Abs(-10) returns 10.

Math.Ceiling() Returns an integer that is greater than or equal to a number.

Math.Ceiling(5.333) returns 6.

Fix() Returns the integer portion of a number.

Fix(5.3333) returns 5.

Math.Floor() Returns an integer that is less than or equal to a number.

Fix(5.3333) returns 5.

Int() Returns the integer portion of a number.

Int(5.3333) returns 5.

Math.Max() Returns the larger of two numbers.

Math.Max(5,7) returns 7.

Math.Min() Returns the smaller of two numbers.

Math.Min(5,7) returns 5.

Math.Pow() Returns a number raised to a power.

Math.Pow(12,2) returns 144.

Rnd() Returns a random number between 0 and 1. Used in conjunction with Randomizestatement to initialize the random number generator.

Math.Round() Rounds a number to a specified number of decimal places. Rounds up on .5.

Math.Round(1.1234567,5) returns 1.12346.

Math.Sign() Returns the sign of a number. Returns -1 if negative and 1 if positive.

Math.Sign(-5) returns -1.

Math.Sqrt() Returns the square root of a positive number.

Math.Sqrt(144) returns 12.
Ebook Download
View all
Learn
View all