> For the complete documentation index, see [llms.txt](https://university-west.gitbook.io/programming-paradigms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/operators/arithmetic.md).

# Arithmetic

#### Arithmetic Operators in Computer Programming

Arithmetic operators are used to perform common mathematical operations. In most programming languages, they include operators for addition, subtraction, multiplication, division, and modulo (remainder of division).

**Types of Arithmetic Operators:**

1. **Addition (`+`):** Adds two operands.
   * **Example:** `5 + 3` results in `8`.
2. **Subtraction (`-`):** Subtracts the second operand from the first.
   * **Example:** `5 - 3` results in `2`.
3. **Multiplication (`*`):** Multiplies two operands.
   * **Example:** `5 * 3` results in `15`.
4. **Division (`/`):** Divides the first operand by the second. Note that in many programming languages, dividing two integers might result in an integer division (meaning it will truncate the decimal part).
   * **Example:** `5 / 2` results in `2.5` in languages with floating-point division or `2` in languages with integer division.
5. **Modulo (`%`):** Returns the remainder of the division of the first operand by the second.
   * **Example:** `5 % 2` results in `1`.

**Examples in Programming Context:**

Consider the following examples in a generic programming language:

```python
# Example Variables
a = 10
b = 5

# Addition
sum = a + b  # sum will be 15

# Subtraction
difference = a - b  # difference will be 5

# Multiplication
product = a * b  # product will be 50

# Division
quotient = a / b  # quotient will be 2.0 (or 2 in integer division)

# Modulo
remainder = a % b  # remainder will be 0
```

**Points to Note:**

* **Division Behavior:** The behavior of the division operator `/` can vary between programming languages. Some languages distinguish between integer division and floating-point division. For example, in Python 2, `5 / 2` equals `2`, whereas in Python 3, it equals `2.5`.
* **Integer Overflow:** In some languages, arithmetic operations with integers can cause overflow if the result exceeds the storage capacity of the integer type.
* **Floating-Point Precision:** Operations with floating-point numbers can lead to precision issues due to the way these numbers are stored in memory.

**Usage:**

Arithmetic operators are widely used in various programming scenarios, such as calculations in scientific computing, financial computations, basic data manipulation, and in the implementation of algorithms. Mastery of these operators is fundamental to effective programming.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/operators/arithmetic.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
