Math operators,
plus (+), minus (-), multiplication (*), and division (/) are defined in all programming languages. They do what you would expect.
Math Operators
Math in a computer language is very similar to math on a calculator, or even the math you do in algebra.
Basic Operators
The basic operations are +, -, /, and *. (plus, minus, division, multiplication). These are the same in all languages.
Language-specific math operations are:
Precedence
Precedence is the order in which a combination of mathematical operations takes place. For example, if you have 5 + 6 - 7 * 8 / 9, do you do the + first, or the /, or perhaps the * or -?
Most programming languages have a list of dozens of precedence rules, but they can be summed up as: (Multiplication and Division) before (Addition and Subtraction).
Left to right for equal precedence
Evaluate expressions in parentheses before anything else!
Examples: 5 + 6 * 7 is equivalent to 5 + (6 * 7), or 47
5 + 6 - 7 is equivalent to (5 + 6). - 7 or 4
5 * (6 - 7) is equivalent to 5 * (6 - 7) or -5.
Math Function Libraries:
Almost all modern programming languages provide a "library" of math functions for use in mathematical programming. These include trig functions…