Mathematical Operators and Functions

Table of Mathematical operators and functions in order of precedence.
Symbol: Operation:
( ) Parenthesis override precedence
^ Exponent
- Negation (indicate negative number)
* , / Multiply and Divide
/ Integer division
MOD Modulous (The remainder of a division)
+ , - Plus and Minus


Notes on Mathematical Operators:
          1) The Negation operator is what is called a Unary operator, which means that there is only one necessary operand to be operated on, so to make a variable negative, all you need to do is set it equal to it's negative self: X = -X
          2) Multiply and Divide are at the same precedence level, as are Add and Subtract. When you have a string of additions and subtractions or Multiplications and Divisions the correct order of evaluation is from left to right.
          3) When you have functions in your equations, like SQRT(X), all functions are evaluated first, and then with those values the order of operations is followed as shown in the table.
          4) These Operators do not work for user-defined types or strings, except for the + operator, which you can use to concatenate strings, that is, add one string to the end of another.


Mathematical Functions Built into QBasic:

ABS(numeric expression)
        This function returns the absoloute value of the numeric expression.
ATN(numeric expression)
        This function returns the arctangent of the numeric expression, where the numeric expression is in radians.
COS(numeric expression)
        This function returns the cosine of the numeric expression, where the numeric expression is in radians.
EXP(numeric expression)
        This function returns e^numeric expression. Where e is eulers number and the numeric expression is less than 88.02969
FIX(numeric expression)
        This function returns the truncated integer part of the numeric expression.
HEX$(numeric expression)
        This function returns the string representation of the numeric expression in Hexadecimal (base-16).
INT(numeric expression)
        This function returns the largest integer less than the numeric expression.
LOG(numeric expression)
        This function returns the natural log of the numeric expression. Where the numeric expression is greater than 0
OCT$(numeric expression)
        This function returns the string representation of the numeric expression in Octal (bas-8).
RND(numeric expression)
        This function This function generates a random number between 0 and 1, this perticular function is kind of complicated and needs explination so it is included in the tutoral.
SGN(numeric expression)
        This function returns the sign of the numeric expression. if the numeric expression is positive it returns +1, if the numeric expression is negative it returns a -1, and if the numeric expression is 0 it returns 0.
SIN(numeric expression)
        This function returns the SIN value of the numeric expression.
SQR(numeric expression)
        This function returns the square root of the numeric expression.
TAN(numeric expression)
        This function returns the tangent of the numeric expression.


Notes on Mathematical Functions:
*none now*

    Back         Main Tutorial Page         Next