# Number Arithmetic & Compounds Assignment

<https://create.roblox.com/docs/luau/operators#arithmetic>\
<https://create.roblox.com/docs/luau/operators#compound-assignment>\
\
In this section, we will be discussing number arithmetics. Number arithmetics can be used to create a math expression for your script. Here are the tables.

### ARITHMETIC

| Operator |    Operation   |
| :------: | :------------: |
|     /    |    Division    |
|    \*    | Multiplication |
|     +    |    Addition    |
|     -    |   Subtraction  |
|     %    |     Modulus    |
|     ^    |    Exponent    |

### COMPOUNDS ASSIGNMENT

| Operator | Operation      |
| -------- | -------------- |
| +=       | Addition       |
| -=       | Subtraction    |
| \*=      | Multiplication |
| /=       | Division       |
| %=       | Modulus        |
| ^=       | Exponentiation |

### **HOW ARITHMETIC WORKS**

**Division** - Division can be used to divide numbers.\
**Multiplication** - Multiplication can be used to multiply numbers.\
**Addition** - Addition can be used to add numbers.\
**Subtraction** - Subtraction can be used to subtract numbers.\
**Modulus** - Modulo can be used to find a reminder of a division.\
**Exponent** - Exponent takes two value called base and power.The base is mulitplied with itself for power times (ex: 5^2 = 5\*5)

### BASIC USAGE

This is how you should use arithmetic and compound assignments in a script.

#### DIVISION

```lua
local Number = 2
print(Number / 2) -- 1
Number = 4
Number /= 2
print(Number) -- 2
```

#### MULTIPLICATION

```lua
local Number = 2
print(Number * 2) -- 4
Number = 4
Number *= 2
print(Number) -- 8
```

#### ADDITION

```lua
local Number = 2
print(Number + 2) -- 4
Number = 4
Number += 2
print(Number) -- 6
```

#### SUBTRACTION

```lua
local Number = 2
print(Number - 2) -- 0
Number = 4
Number -= 2
print(Number) -- 2
```

#### MODULUS

```lua
local Number = 2
print(Number % 2) -- 0
Number = 4
Number %= 3
print(Number) -- 1
```

#### EXPONENT

```lua
local Number = 2
print(Number ^ 2) -- 4
Number = 4
Number ^= 3
print(Number) -- 48
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pretender.gitbook.io/beginners-scripting-guide-beta/number-arithmetic-and-compounds-assignment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
