> For the complete documentation index, see [llms.txt](https://docs.inverter.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inverter.network/contracts/technical-reference/modules/lib/safemath.sol.md).

# 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    |
