---
title: "U2031: A float literal rounds to an infinity, or is not zero and rounds to zero"
url: https://una-lang.org/en/docs/errors/U2031/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U2031.md
---

# U2031: A float literal rounds to an infinity, or is not zero and rounds to zero

A float literal would round to an infinity, or is not zero and would round to zero.

## Why Una rejects it

A float literal denotes the `F64` nearest its exact decimal value (`spec/29`, ADR 0114).

- A literal beyond the largest finite `F64`, `1.7976931348623157e308`, would round to an infinity.
- A literal that is not zero but below half the smallest positive `F64`, `5.0e-324`, would round to zero.

Either way the program would compute with a value other than the one written, so the checker refuses the literal.

A literal that rounds to a subnormal value is accepted.

## How to fix it

- Write `infinity()` when an infinity is meant.
- Write `0.0` when zero is meant.
- Or write a value in range.

## The repair at a glance

`src/demo.una`

```diff
  module demo

- pub tiny() -> F64 = 1.0e-400
+ pub tiny() -> F64 = 0.0
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
```

`src/demo.una`

```una
module demo

pub tiny() -> F64 = 1.0e-400
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
```

`src/demo.una`

```una
module demo

pub tiny() -> F64 = 0.0
```
