# Fixed Point Roll

A set of functions to operate over u64 numbers with 1e9 precision.

## Interface

### <mark style="color:blue;">roll</mark>

**It returns 1 ROLL - 1\_000\_000\_000.**&#x20;

```rust
public fun roll(): u64
```

* **@return u64**. 1e9

### <mark style="color:blue;">try\_mul\_down</mark>

**It tries to `x` \* `y` / 1\_000\_000\_000 rounding down. It returns zero instead of throwing an overflow error.**

```rust
public fun try_mul_down(x: u64, y: u64): (bool, u64)
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return bool.** If the operation was successful.
* **@return u64.** The result of `x` \* `y` / **1\_000\_000\_000**.

### <mark style="color:blue;">try\_mul\_up</mark>

**It tries to `x` \* `y` / 1\_000\_000\_000 rounding up. It returns zero instead of throwing an overflow error.**

```rust
public fun try_mul_up(x: u64, y: u64): (bool, u64)
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return bool.** If the operation was successful.
* **@return u64.** The result of `x` \* `y` / **1\_000\_000\_000**.

### <mark style="color:blue;">try\_div\_down</mark>

**It tries to `x` \* 1\_000\_000\_000 / `y` rounding down. It returns zero instead of throwing an overflow error.**

```rust
public fun try_div_down(x: u64, y: u64): (bool, u64)
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return bool.** If the operation was successful.
* **@return u64.** The result of **`x` \* 1\_000\_000\_000 / `y`**.

### <mark style="color:blue;">try\_div\_up</mark>

**It tries to `x` \* 1\_000\_000\_000 / `y` rounding up. It returns zero instead of throwing an overflow error.**

```rust
public fun try_div_up(x: u64, y: u64): (bool, u64)
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return bool.** If the operation was successful.
* **@return u64.** The result of **`x` \* 1\_000\_000\_000 / `y`**.

### <mark style="color:blue;">mul\_down</mark>

`x` \* `y` / **1\_000\_000\_000** rounding down.

```rust
public fun mul_down(x: u64, y: u64): u64
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return u64.** The result of `x` \* `y` / **1\_000\_000\_000**.

**Aborts**

* On overflow. If the result is over the maximum u256 number.

### <mark style="color:blue;">mul\_up</mark>

`x` \* `y` / **1\_000\_000\_000** rounding up.

```rust
public fun mul_up(x: u64, y: u64): u64
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return u64.** The result of `x` \* `y` / **1\_000\_000\_000**.

**Aborts**

* On overflow. If the result is over the maximum u256 number.

### <mark style="color:blue;">div\_down</mark>

`x` \*  **1\_000\_000\_000** / `y` rounding down.

```rust
public fun div_down(x: u64, y: u64): u64
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return u64.** The result of `x` \*  **1\_000\_000\_000** / `y`.

**Aborts**

* On zero division.

### <mark style="color:blue;">div\_up</mark>

`x` \*  **1\_000\_000\_000** / `y` rounding up.

```rust
public fun div_up(x: u64, y: u64): u64
```

* **@param x:** The first operand.
* **@param y:** The second operand.
* **@return u64.** The result of `x` \*  **1\_000\_000\_000** / `y`.

**Aborts**

* On zero division.

### <mark style="color:blue;">to\_roll</mark>

**It converts `x` precision to a `ROLL`, a number with a precision of 1e9.**

```rust
public fun to_roll(x: u64, decimal_factor: u64): u64
```

* **@param x:** The value to be converted.
* **@param decimal\_factor:** The current decimal scalar of x.&#x20;
* **@return u64.** The result of `x` \*  **1\_000\_000\_000** / `y`.

**Aborts**

* decimal\_factor is zero.


---

# 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.interestprotocol.com/overview/deprecated/sui-tears/math/fixed-point-roll.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.
