BB___Mathematical_Operators

=Mathematical operators= toc

Description
JB mathematical operators list:
 * = **Operator** ||  ||= **Meaning** ||
 * = ``^`` ||  ||= Power (Exponentiation) ||
 * = ``*`` ||  ||= Multiplication ||
 * = ``/`` ||  ||= Division ||
 * = MOD ||  ||= Modulus (Remainder of a Division) ||
 * = ``+`` ||  ||= Addition ||
 * = ``-`` ||  ||= Subtraction ||

General syntax
> //numerical_expression// operator //numerical_expression// Result is a numerical expression.

If there are several operators in an expression, they are evaluated by rules of precedence within the same precedence - from left to right.
 * first: ^
 * second: * / mod
 * third: + -

If you need another evaluation order or you are not sure, use parentheses:, expressions within parentheses are evaluated inside-out.

Hints
> Just Basic supports operations on arbitrary-length integers, see Numbers. When working with integers, all operations except division return an integer (possibly long integer). There is no special integer division, if a and b are integers, and a/b happens to return an integer, you get an (may be long) integer, otherwise you get a Double (a floating point value with 16 significant digits and a maximum range of about +/- 1e307). > But if you take INT(a/b) where a is a long integer and b is a (possibly long) integer, then you can get a long integer. It is probably due to JB not storing intermediate results as floating point until it has to.

> Exponentiation operator (^, a^b reads as "a to the power of b") is defined in mathematics so that, if a>0, then b could be any number; but if a<0, then b must be an integer.

> The MOD operator could be described as >> a MOD b = a - INT(a/b)*b >> "all we get when we subtract b from a till the remaining number is less than b" >> > Note that in JB for negative a the result of a MOD b is negative. > The MOD operator is very handy for wrapping indexes around, just remember that a MOD b for integers a and b produces numbers from 0 to b-1. > Wrapping things around is nicely illustrated by the day of week concept (see the DATE$ function).

Example
code format="vbnet" Place a simple, working example of the keyword here code

Useful Procedures
code format="vbnet" Place a useful procedure using this keyword here code