> For the complete documentation index, see [llms.txt](https://docs.internetobject.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.internetobject.org/schema-definition-language/data-types/decimal.md).

# Decimal

The **`decimal`** type validates an exact, fixed-precision decimal — for money and other values where binary floating point would lose accuracy. In data it is written with an `m` suffix: `123.45m`.

> For the literal syntax, see [Decimal values](/structure-and-syntax/values/number/decimal.md).

## TypeDef

A `decimal` MemberDef accepts only the options below. Any other key is invalid.

| Option       | Type             | Description                                                     |
| ------------ | ---------------- | --------------------------------------------------------------- |
| `type`       | string           | The type name `decimal`. First positional value.                |
| `default`    | decimal          | Value used when the member is omitted. Second positional value. |
| `choices`    | array of decimal | Restricts the value to a fixed set.                             |
| `precision`  | int              | Maximum total number of significant digits.                     |
| `scale`      | int              | Exact number of digits after the decimal point.                 |
| `min`        | decimal          | Minimum allowed value (inclusive).                              |
| `max`        | decimal          | Maximum allowed value (inclusive).                              |
| `multipleOf` | decimal          | The value must be an exact multiple of this.                    |
| `optional`   | bool             | If `true`, the member may be omitted. Shorthand: `?` suffix.    |
| `null`       | bool             | If `true`, the member may be `null`. Shorthand: `*` suffix.     |

### No format option

Unlike the other numeric types, `decimal` has **no `format` option** — and this is deliberate, not an omission. A `format` selects among the literals that can express a value, and a decimal has only one: `<digits>.<digits>m`. Radix notations cannot express a fractional value, and [scientific notation is not part of the decimal literal](/structure-and-syntax/values/number/decimal.md) (`1.23e2m` is invalid). With a single possible spelling there is nothing to select.

The `m` suffix is always written; without it the output would read back as a plain number.

## Precision & scale

`precision` and `scale` together give SQL-style `DECIMAL(precision, scale)` validation:

* **scale** — the number of fractional digits MUST equal `scale`.
* **precision** — the total significant digits MUST NOT exceed `precision`.

```ruby
price: { decimal, precision: 5, scale: 2 }
---
~ 123.45m    # ✓  (5 digits, 2 after the point)
```

```ruby
rate: { decimal, scale: 2 }
---
~ 1.5m       # ✗ invalid-scale  (1 fractional digit, scale requires 2)
```

> With neither `precision` nor `scale`, a `decimal` is compared by its exact value.

## Optional, nullable & defaults

Resolution follows the [common rules](/schema-definition-language/data-types/number.md#optional-nullable--defaults):

```ruby
amount?*: decimal
---
~ {}      # ✓ omitted → absent
~ N       # ✓ null
~ 9.99m   # ✓
```

## See Also

* [Decimal values](/structure-and-syntax/values/number/decimal.md)
* [Numeric Types](/schema-definition-language/data-types/number.md) · [BigInt](/schema-definition-language/data-types/bigint.md)
* [TypeDef](/schema-definition-language/advanced-schema-concepts/typedef.md) · [MemberDef](/schema-definition-language/advanced-schema-concepts/memberdef.md)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.internetobject.org/schema-definition-language/data-types/decimal.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
