# SafeMath.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/lib/SafeMath.sol)

**Author:** <https://github.com/AragonBlack/fundraising/blob/master/apps/bancor-formula/contracts/utility/SafeMath.sol>

The sole modification implemented in the contract involves altering the Solidity version number.

### Functions

#### add

*returns the sum of \_x and \_y, reverts if the calculation overflows*

```solidity
function add(uint _x, uint _y) internal pure returns (uint);
```

**Parameters**

| Name | Type      | Description |
| ---- | --------- | ----------- |
| `_x` | `uint256` | value 1     |
| `_y` | `uint256` | value 2     |

**Returns**

| Name     | Type      | Description |
| -------- | --------- | ----------- |
| `<none>` | `uint256` | sum         |

#### sub

*returns the difference of \_x minus \_y, reverts if the calculation underflows*

```solidity
function sub(uint _x, uint _y) internal pure returns (uint);
```

**Parameters**

| Name | Type      | Description |
| ---- | --------- | ----------- |
| `_x` | `uint256` | minuend     |
| `_y` | `uint256` | subtrahend  |

**Returns**

| Name     | Type      | Description |
| -------- | --------- | ----------- |
| `<none>` | `uint256` | difference  |

#### mul

*returns the product of multiplying \_x by \_y, reverts if the calculation overflows*

```solidity
function mul(uint _x, uint _y) internal pure returns (uint);
```

**Parameters**

| Name | Type      | Description |
| ---- | --------- | ----------- |
| `_x` | `uint256` | factor 1    |
| `_y` | `uint256` | factor 2    |

**Returns**

| Name     | Type      | Description |
| -------- | --------- | ----------- |
| `<none>` | `uint256` | product     |

#### div

*Integer division of two numbers truncating the quotient, reverts on division by zero.*

```solidity
function div(uint _x, uint _y) internal pure returns (uint);
```

**Parameters**

| Name | Type      | Description |
| ---- | --------- | ----------- |
| `_x` | `uint256` | dividend    |
| `_y` | `uint256` | divisor     |

**Returns**

| Name     | Type      | Description |
| -------- | --------- | ----------- |
| `<none>` | `uint256` | quotient    |


---

# 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://docs.inverter.network/contracts/technical-reference/modules/lib/safemath.sol.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.
