Introduction of Arithmetic Operations

This section provides a quick introduction of arithmetic operations supported by VBScript: addition, subtraction, multiplication, division, remainder, and exponentiation.

VBScript supports 8 arithmetic operations:

• Addition (+): Returns the mathematical sum of both operands.
• Subtraction (-): Returns the result of the first operand subtracted by the second operand.
• Unary Negation (-): Returns the negative value of the only operand.
• Multiplication (*): Returns the result of the first operand multiplied by the second operand.
• Division (/): Returns the result of the first divided by the second operand.
• Integer Division (\): Returns the result of the first operand divided by the second operand. Both operands are rounded to integer values before the operation. The decimal fraction part is removed from the resulting value.
• Modulus (also called Remainder) (Mod): Returns the remainder of the first operand divided by the second operand. Both operands are rounded to integer values before the operation.
• Exponentiation (^): Returns the first operand raised to the power of the second operand.

To show you some simple arithmetic operations, I wrote the following script, arithmetic_operation.html:

```<html>
<body>
<!-- arithmetic_operation.html
-->
<pre>
<script language="vbscript">
document.writeln("1 + 1 = " & (1 + 1))
document.writeln("0 - 3 = " & (0 - 3))
document.writeln("- 3 = " & (- 3))
document.writeln("9 * 9 = " & (9 * 9))
document.writeln("20 / 3 = " & (20 / 3))
document.writeln("20 \ 3 = " & (20 \ 3))
document.writeln("20 Mod 3 = " & (20 Mod 3))
document.writeln("3 ^ 4 = " & (3 ^ 4))
</script>
</pre>
</body>
</html>
```

Here is the output of this VBScript example script:

```1 + 1 = 2
0 - 3 = -3
- 3 = -3
9 * 9 = 81
20 / 3 = 6.66666666666667
20 \ 3 = 6
20 Mod 3 = 2
3 ^ 4 = 81
```