---
title: "U2037: A decimal scale out of place"
url: https://una-lang.org/en/docs/errors/U2037/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2037.md
---

# U2037: A decimal scale out of place

In edition `0.5` (preview), a decimal scale is in a place where it would not fit.

## Why Una rejects it

A `Decimal[s]` holds an exact number with s digits after the point, and its scale is part of the type (`spec/29 §16`, ADR 0120). The scale is an integer literal from 0 to 38. A value never loses a digit silently, so the checker refuses every place where a scale would not fit:

- a scale above 38, or a `Decimal` type without its scale in brackets;
- a float literal with a nonzero digit beyond the scale it takes, such as `19.995` as a `Decimal[2]`, also as the other operand of `+`, `-` or `*`, where the literal takes that operand's scale and never widens it;
- a literal whose coefficient would have more than 4,300 digits, the language's digit cap;
- a product whose scale, the sum of its operands' scales, is above 38;
- `widen` to a smaller scale, and `rescale` or `rescale_exact` to a scale that is not smaller;
- a scale argument, `scale:`, that is not an integer literal.

## How to fix it

- Give the literal its own type (`let fee: Decimal[3] = 0.005`).
- Write fewer digits.
- Rescale an operand first.
- Or use the method that matches the direction of the change: `widen` adds digits, `rescale` drops them with a written rounding mode.

## The repair at a glance

`src/demo.una`

```diff
  module demo

- pub price() -> Decimal[2] = 19.995
+ pub price() -> Decimal[3] = 19.995
```

## Failing example

`ita.una`

```una
ita demo
  version 0.1.0
  edition 0.5
```

`ita.lock`

```una
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0
```

`src/demo.una`

```una
module demo

pub price() -> Decimal[2] = 19.995
```

## Fixed example

`ita.una`

```una
ita demo
  version 0.1.0
  edition 0.5
```

`ita.lock`

```una
lock 1

solver
  encoding "una-smt-1"
  name "z3"
  version "5.1.0"
  logic "QF_UFLIA"
  steps 5000000
  seed 0
```

`src/demo.una`

```una
module demo

pub price() -> Decimal[3] = 19.995
```
