# Difference between revisions of "Mathematical Operations"

Jump to navigation
Jump to search

imported>Clippy |
imported>Clippy |
||

Line 4: | Line 4: | ||

: Most of the BASIC math operators are ones that require no introduction. The addition, subtraction, multplication and division operators are ones commonly used as shown below: | : Most of the BASIC math operators are ones that require no introduction. The addition, subtraction, multplication and division operators are ones commonly used as shown below: | ||

− | ::::::::: + .... Addition: a + b | + | ::::::::: + .... Addition: c = a + b |

− | ::::::::: - .... Subtraction: a - b | + | ::::::::: - .... Subtraction: c = a - b |

− | ::::::::: * .... Multiplication: a * b | + | ::::::::: * .... Multiplication: c = a * b |

− | ::::::::: / .... Division: a / b | + | ::::::::: / .... Division: c = a / b |

:BASIC can also use two other operators for [[INTEGER]] division. Integer division returns only whole number values. MOD or remainder division returns a value only if an integer division cannot divide a number evenly. | :BASIC can also use two other operators for [[INTEGER]] division. Integer division returns only whole number values. MOD or remainder division returns a value only if an integer division cannot divide a number evenly. | ||

− | ::::::::: \ .... Integer division: a \ b | + | ::::::::: \ .... Integer division: c = a \ b |

− | :::::::: [[MOD]] .... Remainder division: a MOD b | + | :::::::: [[MOD]] .... Remainder division: c = a MOD b |

: There are also a couple of operators for exponential calculations. The exponetial operator is used to raise a number's value to a designated exponent of itself. The SQR function returns a number's Square Root. For other roots the exponential operator can be used with fractions such as 1 / 3 designating the cube root of a number. | : There are also a couple of operators for exponential calculations. The exponetial operator is used to raise a number's value to a designated exponent of itself. The SQR function returns a number's Square Root. For other roots the exponential operator can be used with fractions such as 1 / 3 designating the cube root of a number. | ||

− | ::::::::: ^ .... Exponent: a ^ b | + | ::::::::: ^ .... Exponent: c = a ^ 2 + b ^ 2 |

− | :::::::: [[SQR]](n) .... Square root: SQR(a) | + | :::::::: [[SQR]](n) .... Square root: c = SQR(a) |

## Revision as of 04:21, 25 September 2009

**BASIC Mathematical Operations**

- Most of the BASIC math operators are ones that require no introduction. The addition, subtraction, multplication and division operators are ones commonly used as shown below:

- + .... Addition: c = a + b
- - .... Subtraction: c = a - b
- * .... Multiplication: c = a * b
- / .... Division: c = a / b

- BASIC can also use two other operators for INTEGER division. Integer division returns only whole number values. MOD or remainder division returns a value only if an integer division cannot divide a number evenly.

- \ .... Integer division: c = a \ b

- MOD .... Remainder division: c = a MOD b

- There are also a couple of operators for exponential calculations. The exponetial operator is used to raise a number's value to a designated exponent of itself. The SQR function returns a number's Square Root. For other roots the exponential operator can be used with fractions such as 1 / 3 designating the cube root of a number.

- ^ .... Exponent: c = a ^ 2 + b ^ 2

- SQR(n) .... Square root: c = SQR(a)

**BASIC's Order of Operations**

- When a normal calculation is made BASIC works from left to right, but it does certain calculations in the following order:

- 1) Exponential and exponential Root calculations
- 2) Multiplication and Division calculations
- 3) Addition and Subtraction calculations

- Some times a calculation may need BASIC to do them in another order or the calculation will return bad results. BASIC allows the programmer to decide the order of operations by using parenthesis around parts of the equation. BASIC will do those calculations first and the others from left to right in the operation order.

**Numerical Signs**

- Calculations can be affected when using negative number values. There are two functions to determine the number's sign and change negative values to positive.