# Introduction to Numeric Functions in vb.net

The .NET Framework has too many numeric functions that can be used out of the box for numeric manipulation. This article is to learn about the most common ones that each developer should know.

# The Numeric Functions in VB.NET

All numeric functions that are available VB.NET are implemented as the constant and static methods of Math Class, which is inherited from the Object class. For using any of Math methods from the Math class, you should use the methods with the word “Math.”, Or import the whole class using the keyword “imports” in VB.NET, and “using” in C#. Few of these functions and their usage and overload list are mentioned below:

Abs(int): This method returns about the absolute value of a particular number.

```Dim x As Integer
x = -2
Console.WriteLine(Abs(x))
```

Output

`2`

Abs(Decimal)
Abs(Double)
Abs(Int16)
Abs(Int32)
Abs(Int64)
Abs(SByte)
Abs(Single)

Ceiling(Double): This function returns the smallest integral value that is greater than or equal to a Number.

```Dim x As Double
x = 2.56
Console.WriteLine(Ceiling(x))
```

Output

`3`

Ceiling(Decimal)
Ceiling(Double)

Floor(Double): This function returns the largest integer value that is less than or equal to a numeric value.

```Dim x As Double
x = 2.56
Console.WriteLine(Floor(x))```

Output

`2`

Floor(Decimal)
Floor(Double)

Log(Double): This function returns the base e logarithm of the double value.

```Dim x As Double
x = 10
Console.WriteLine(Log(x))```

Output

`2.30258509299405`

Log(Double)
Log(Double, Double)  Note: the 2nd Double argument is for the log base.

Log10(Double):  This function returns the base 10 logarithm of the double value.

```Dim x As Double
x = 10
Console.WriteLine(Log10(x))```

Output

`1`

Min(int,int): This function compares two numbers and returns the smallest one.

```Dim x, y As Integer
x = -2
y = 7
Console.WriteLine(Min(x, y))```

Output

`2`

Min(Byte, Byte)
Min(Decimal, Decimal)
Min(Double, Double)
Min(Int16, Int16)
Min(Int32, Int32)
Min(Int64, Int64)
Min(SByte, SByte)
Min(Single, Single)
Min(UInt16, UInt16)
Min(UInt32, UInt32)
Min(UInt64, UInt64)

Max(int,int): The function compares two  numbers and returns the biggest one.

```Dim x, y As Integer
x = -2
y = 7
Console.WriteLine(Max(x, y))```

Output

`7`

Max(Byte, Byte)
Max(Decimal, Decimal)
Max(Double, Double)
Max(Int16, Int16)
Max(Int32, Int32)
Max(Int64, Int64)
Max(SByte, SByte)
Max(Single, Single)
Max(UInt16, UInt16)
Max(UInt32, UInt32)
Max(UInt64, UInt64)

Round(int): This function rounds a number to the nearest integral value.

```Dim x As Integer
x = 2.6
Console.WriteLine(Round(x))```

Output

`3`

Round(Decimal)
Round(Decimal, Int32)
Round(Decimal, Int32, MidpointRounding)
Round(Decimal, MidpointRounding)
Round(Double)
Round(Double, Int32)
Round(Double, Int32, MidpointRounding)
Round(Double, MidpointRounding)

Pow(Double,Double): The function returns the particular number which is raised at a specific power. For example, if the parameters are a and b, the output will also return a^b.

```Dim x, y As Double
x = 2
y = 3
Console.WriteLine(Pow(x, y))```

Output

`8`

Sqrt(Double): The function returns the square root of a particular number.

```Dim x As Double
x = 25
Console.WriteLine(Sqrt(x))```

Output

`5`

Related Articles: 