ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

05-Math Functions

The System.Math class provide methods such as trigonometric, logarithmic, and other common mathematical functions that is used in Visual Basic program.

 

Feel free to visit this site msdn.microsoft.com to see the lists of methods of the System.Math class.

 

In programming ,  mathematical functions are very useful because often times we need to deal with mathematical concepts in programming such as  mathematical logics, coordinates, variables,  calculations, time intervals and etc. In Visual Basic, the most common mathematical functions are Sqrt, Int, Abs, Exp, Round, Log , Sin, Cos, Tan , Rnd   and  Atn .

 

Example:

  1. For x As Integer = 1 To 10
  2. MsgBox(Rnd)
  3. Next x

The numeric functions are Sqrt, Int, Abs, Exp, Round and Log.

  • Sqrt computes the square root of a number.
    example:
    Sqrt(36)=6
    Sqrt(49)=7

 

  • Int converts a number into an integer by truncating its decimal part and the resulting integer is the largest integer that is smaller than the number.
    example:
    Int(3.3)=3
    Int(5.5)=5
    Int(-5.7)= -6

 

  •  Abs returns the absolute value of a number.
    example:
    Abs(-9) = 9
    Abs(9)= 9

 

  • Exp of number x is the value of ex. NOTE: e is a mathematical constant whose value is approximately 2.71828.
    example:
    Exp(1)=2.71828
    Exp(2) = 7.38905609893065

 

  • Round rounds up a number to a certain number of decimal places.
    example:
    Round (8.2567, 2) =8.26

 

  • Log returns the natural Logarithm of a number.
    example,
    Log10(99.3)=1.99694924849538
Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!