> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FixedNumber

A FixedNumber represents a value over its [**FixedFormat**](/sdk/content/type-aliases/FixedFormat) arithmetic field.

A FixedNumber can be used to perform math, losslessly, on values which have decmial places.

A FixedNumber has a fixed bit-width to store values in, and stores all values internally by multiplying the value by
10 raised to the power of `decimals`.

If operations are performed that cause a value to grow too high (close to positive infinity) or too low (close to
negative infinity), the value is said to overflow.

For example, an 8-bit signed value, with 0 decimals may only be within the range `-128` to `127`; so `-128 - 1` will
overflow and become `127`. Likewise, `127 + 1` will overflow and become `-127`.

Many operation have a normal and unsafe variant. The normal variant will throw a
[NumericFaultError](../interfaces/NumericFaultError) on any overflow, while the unsafe variant will silently allow
overflow, corrupting its value value.

If operations are performed that cause a value to become too small (close to zero), the value loses precison and is
said to underflow.

For example, an value with 1 decimal place may store a number as small as `0.1`, but the value of `0.1 / 2` is
`0.05`, which cannot fit into 1 decimal place, so underflow occurs which means precision is lost and the value
becomes `0`.

Some operations have a normal and signalling variant. The normal variant will silently ignore underflow, while the
signalling variant will thow a [NumericFaultError](../interfaces/NumericFaultError) on underflow.

## Properties

| Property | Modifier   | Type     | Description                                               |
| :------- | :--------- | :------- | :-------------------------------------------------------- |
| `format` | `readonly` | `string` | The specific fixed-point arithmetic field for this value. |

## Accessors

### decimals

```ts theme={null}
get decimals(): number
```

The number of decimal places in the fixed-point arithment field.

#### Returns

`number`

#### Source

[utils/fixednumber.ts:266](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L266)

***

### signed

```ts theme={null}
get signed(): boolean
```

If true, negative values are permitted, otherwise only positive values and zero are allowed.

#### Returns

`boolean`

#### Source

[utils/fixednumber.ts:252](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L252)

***

### value

```ts theme={null}
get value(): bigint
```

The value as an integer, based on the smallest unit the [**decimals**](/sdk/content/classes/FixedNumber#decimals) allow.

#### Returns

`bigint`

#### Source

[utils/fixednumber.ts:273](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L273)

***

### width

```ts theme={null}
get width(): number
```

The number of bits available to store the value.

#### Returns

`number`

#### Source

[utils/fixednumber.ts:259](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L259)

## Methods

### add()

```ts theme={null}
add(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` added to `other`. A
[NumericFaultError](../interfaces/NumericFaultError) is thrown if overflow occurs.

#### Parameters

| Parameter | Type                                              | Description                 |
| :-------- | :------------------------------------------------ | :-------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to add to `this`. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the addition.

#### Source

[utils/fixednumber.ts:308](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L308)

***

### addUnsafe()

```ts theme={null}
addUnsafe(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` added to `other`, ignoring overflow.

#### Parameters

| Parameter | Type                                              | Description                 |
| :-------- | :------------------------------------------------ | :-------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to add to `this`. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the addition.

#### Source

[utils/fixednumber.ts:297](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L297)

***

### ceiling()

```ts theme={null}
ceiling(): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) which is the smallest **integer** that is greater than or
equal to `this`.

The decimal component of the result will always be `0`.

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The ceiling value.

#### Source

[utils/fixednumber.ts:549](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L549)

***

### cmp()

```ts theme={null}
cmp(other): number
```

Returns a comparison result between `this` and `other`.

This is suitable for use in sorting, where `-1` implies `this` is smaller, `1` implies `this` is larger and `0`
implies both are equal.

#### Parameters

| Parameter | Type                                              | Description                     |
| :-------- | :------------------------------------------------ | :------------------------------ |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to compare to `this`. |

#### Returns

`number`

The comparison result.

#### Source

[utils/fixednumber.ts:452](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L452)

***

### div()

```ts theme={null}
div(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` divided by `other`, ignoring
underflow (precision loss). A [NumericFaultError](../interfaces/NumericFaultError) is thrown if overflow occurs.

#### Parameters

| Parameter | Type                                              | Description                    |
| :-------- | :------------------------------------------------ | :----------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to divide `this` by. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the division.

#### Source

[utils/fixednumber.ts:415](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L415)

***

### divSignal()

```ts theme={null}
divSignal(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` divided by `other`. A
[NumericFaultError](../interfaces/NumericFaultError) is thrown if underflow (precision loss) occurs.

#### Parameters

| Parameter | Type                                              | Description                    |
| :-------- | :------------------------------------------------ | :----------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to divide `this` by. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the division.

#### Throws

Thrown if underflow occurs.

#### Source

[utils/fixednumber.ts:427](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L427)

***

### divUnsafe()

```ts theme={null}
divUnsafe(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` divided by `other`, ignoring
underflow (precision loss). A [NumericFaultError](../interfaces/NumericFaultError) is thrown if overflow occurs.

#### Parameters

| Parameter | Type                                              | Description                    |
| :-------- | :------------------------------------------------ | :----------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to divide `this` by. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the division.

#### Source

[utils/fixednumber.ts:404](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L404)

***

### eq()

```ts theme={null}
eq(other): boolean
```

Returns true if `other` is equal to `this`.

#### Parameters

| Parameter | Type                                              | Description                     |
| :-------- | :------------------------------------------------ | :------------------------------ |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to compare to `this`. |

#### Returns

`boolean`

True if `other` is equal to `this`.

#### Source

[utils/fixednumber.ts:480](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L480)

***

### floor()

```ts theme={null}
floor(): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) which is the largest **integer** that is less than or equal to
`this`.

The decimal component of the result will always be `0`.

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The floored value.

#### Source

[utils/fixednumber.ts:532](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L532)

***

### gt()

```ts theme={null}
gt(other): boolean
```

Returns true if `other` is greater than to `this`.

#### Parameters

| Parameter | Type                                              | Description                     |
| :-------- | :------------------------------------------------ | :------------------------------ |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to compare to `this`. |

#### Returns

`boolean`

True if `other` is greater than to `this`.

#### Source

[utils/fixednumber.ts:510](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L510)

***

### gte()

```ts theme={null}
gte(other): boolean
```

Returns true if `other` is greater than or equal to `this`.

#### Parameters

| Parameter | Type                                              | Description                     |
| :-------- | :------------------------------------------------ | :------------------------------ |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to compare to `this`. |

#### Returns

`boolean`

True if `other` is greater than or equal to `this`.

#### Source

[utils/fixednumber.ts:520](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L520)

***

### isNegative()

```ts theme={null}
isNegative(): boolean
```

Returns true if `this` is less than `0`.

#### Returns

`boolean`

True if `this` is less than `0`.

#### Source

[utils/fixednumber.ts:601](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L601)

***

### isZero()

```ts theme={null}
isZero(): boolean
```

Returns true if `this` is equal to `0`.

#### Returns

`boolean`

True if `this` is equal to `0`.

#### Source

[utils/fixednumber.ts:592](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L592)

***

### lt()

```ts theme={null}
lt(other): boolean
```

Returns true if `other` is less than to `this`.

#### Parameters

| Parameter | Type                                              | Description                     |
| :-------- | :------------------------------------------------ | :------------------------------ |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to compare to `this`. |

#### Returns

`boolean`

True if `other` is less than to `this`.

#### Source

[utils/fixednumber.ts:490](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L490)

***

### lte()

```ts theme={null}
lte(other): boolean
```

Returns true if `other` is less than or equal to `this`.

#### Parameters

| Parameter | Type                                              | Description                     |
| :-------- | :------------------------------------------------ | :------------------------------ |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to compare to `this`. |

#### Returns

`boolean`

True if `other` is less than or equal to `this`.

#### Source

[utils/fixednumber.ts:500](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L500)

***

### mul()

```ts theme={null}
mul(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` multiplied by `other`. A
[NumericFaultError](../interfaces/NumericFaultError) is thrown if overflow occurs.

#### Parameters

| Parameter | Type                                              | Description                      |
| :-------- | :------------------------------------------------ | :------------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to multiply `this` by. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the multiplication.

#### Source

[utils/fixednumber.ts:362](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L362)

***

### mulSignal()

```ts theme={null}
mulSignal(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` multiplied by `other`. A
[NumericFaultError](../interfaces/NumericFaultError) is thrown if overflow occurs or if underflow (precision
loss) occurs.

#### Parameters

| Parameter | Type                                              | Description                      |
| :-------- | :------------------------------------------------ | :------------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to multiply `this` by. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the multiplication.

#### Throws

Thrown if overflow or underflow occurs.

#### Throws

Thrown if division by 0 occurs.

#### Source

[utils/fixednumber.ts:376](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L376)

***

### mulUnsafe()

```ts theme={null}
mulUnsafe(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `this` multiplied by `other`, ignoring
overflow and underflow (precision loss).

#### Parameters

| Parameter | Type                                              | Description                      |
| :-------- | :------------------------------------------------ | :------------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to multiply `this` by. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the multiplication.

#### Source

[utils/fixednumber.ts:351](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L351)

***

### round()

```ts theme={null}
round(decimals?): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the decimal component rounded up on ties at `decimals`
places.

#### Parameters

| Parameter   | Type     | Description                               |
| :---------- | :------- | :---------------------------------------- |
| `decimals`? | `number` | The number of decimal places to round to. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The rounded value.

#### Source

[utils/fixednumber.ts:565](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L565)

***

### sub()

```ts theme={null}
sub(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `other` subtracted from `this`. A
[NumericFaultError](../interfaces/NumericFaultError) is thrown if overflow occurs.

#### Parameters

| Parameter | Type                                              | Description                        |
| :-------- | :------------------------------------------------ | :--------------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to subtract from `this`. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the subtraction.

#### Source

[utils/fixednumber.ts:335](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L335)

***

### subUnsafe()

```ts theme={null}
subUnsafe(other): FixedNumber
```

Returns a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the result of `other` subtracted from `this`, ignoring
overflow.

#### Parameters

| Parameter | Type                                              | Description                        |
| :-------- | :------------------------------------------------ | :--------------------------------- |
| `other`   | [`FixedNumber`](/sdk/content/classes/FixedNumber) | The value to subtract from `this`. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The result of the subtraction.

#### Source

[utils/fixednumber.ts:324](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L324)

***

### toFormat()

```ts theme={null}
toFormat(format): FixedNumber
```

Return a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the same value but has had its field set to `format`.

This will throw if the value cannot fit into `format`.

#### Parameters

| Parameter | Type                                                   | Description                   |
| :-------- | :----------------------------------------------------- | :---------------------------- |
| `format`  | [`FixedFormat`](/sdk/content/type-aliases/FixedFormat) | The new format for the value. |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

#### Source

[utils/fixednumber.ts:633](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L633)

***

### toString()

```ts theme={null}
toString(): string
```

Returns the string representation of `this`.

#### Returns

`string`

The string representation.

#### Source

[utils/fixednumber.ts:610](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L610)

***

### toUnsafeFloat()

```ts theme={null}
toUnsafeFloat(): number
```

Returns a float approximation.

Due to IEEE 754 precission (or lack thereof), this function can only return an approximation and most values will
contain rounding errors.

#### Returns

`number`

The float approximation.

#### Source

[utils/fixednumber.ts:622](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L622)

***

### fromBytes()

```ts theme={null}
static fromBytes(_value, _format?): FixedNumber
```

Creates a new [**FixedNumber**](/sdk/content/classes/FixedNumber) with the big-endian representation `value` with `format`.

This will throw a [NumericFaultError](../interfaces/NumericFaultError) if `value` cannot fit in `format` due to
overflow.

#### Parameters

| Parameter  | Type                                                   | Description                                 |
| :--------- | :----------------------------------------------------- | :------------------------------------------ |
| `_value`   | [`BytesLike`](/sdk/content/type-aliases/BytesLike)     | The big-endian representation of the value. |
| `_format`? | [`FixedFormat`](/sdk/content/type-aliases/FixedFormat) | The format for the FixedNumber.             |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The FixedNumber for `value`.

#### Source

[utils/fixednumber.ts:727](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L727)

***

### fromString()

```ts theme={null}
static fromString(_value, _format?): FixedNumber
```

Creates a new [**FixedNumber**](/sdk/content/classes/FixedNumber) for `value` with `format`.

This will throw a [NumericFaultError](../interfaces/NumericFaultError) if `value` cannot fit in `format`, either
due to overflow or underflow (precision loss).

#### Parameters

| Parameter  | Type                                                   | Description                            |
| :--------- | :----------------------------------------------------- | :------------------------------------- |
| `_value`   | `string`                                               | The value to create a FixedNumber for. |
| `_format`? | [`FixedFormat`](/sdk/content/type-aliases/FixedFormat) | The format for the FixedNumber.        |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The FixedNumber for `value`.

#### Source

[utils/fixednumber.ts:681](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L681)

***

### fromValue()

```ts theme={null}
static fromValue(
   _value, 
   _decimals?, 
   _format?): FixedNumber
```

Creates a new [**FixedNumber**](/sdk/content/classes/FixedNumber) for `value` divided by `decimal` places with `format`.

This will throw a [NumericFaultError](../interfaces/NumericFaultError) if `value` (once adjusted for `decimals`)
cannot fit in `format`, either due to overflow or underflow (precision loss).

#### Parameters

| Parameter    | Type                                                     | Description                              |
| :----------- | :------------------------------------------------------- | :--------------------------------------- |
| `_value`     | [`BigNumberish`](/sdk/content/type-aliases/BigNumberish) | The value to create a FixedNumber for.   |
| `_decimals`? | [`Numeric`](/sdk/content/type-aliases/Numeric)           | The number of decimal places in `value`. |
| `_format`?   | [`FixedFormat`](/sdk/content/type-aliases/FixedFormat)   | The format for the FixedNumber.          |

#### Returns

[`FixedNumber`](/sdk/content/classes/FixedNumber)

The FixedNumber for `value`.

#### Source

[utils/fixednumber.ts:648](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fixednumber.ts#L648)
