Math Functions

[ Using VB ]

    Math functions, along with other functions, are used in almost every program.  As you read about these functions on this page, you could see how useful some of them can be.

Abs

Exp Log

Sin

Atn Fix Rnd

Sqr

Cos Int Sgn Tan

Abs Function -

    This functions returns the absolute value of the given value.   That is, it eliminates the sign in front of the number.  So, Abs(-1) returns 1, and Abs(1) also returns a 1.


Atn Function -

    This function is the arctangent of the given value.  The function returns the value as a double.


Cos Function -

    Returns the Cosine of the angle given.


Exp Function -

    Returns a Double value of e raised to a power.  A.K.A. antilogarithm.


Fix Function -

    Removes the fractional part of an integer.  When dealing with negative numbers, Fix rounds up.


Int Function -

    Removes the fractional part of an integer.  When dealing with negative numbers, Int rounds down.


Log Function -

    Returns the logarithm of a number.


Rnd Function -

    Generates a random number.  The basic syntax for this one is:

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    If you have 31 kids in a classroom, and you want to pick one, then this would work.  First of all, upperbound = 31 and lowerbound = 1.   When put into the function, you get:
                    Int((31 - 1 + 1) * Rnd + 1)  or  Int(31 * Rnd + 1)


Sgn Function -

    This function gets the sign of a number.  If the function returns a 1, than the number is greater than 0.  If the function returns a 0, than the number is 0.  If the function returns a -1, then the number is less than 0.


Sin Function -

    The function returns a double that is the sine of an angle.


Sqr Function -

    This function is the square root of a number.  (ex:   Sqr(9) returns a 3)


Tan Function -

    Returns the Tangent of the number in double format.