Home / Docs / Diagnostics

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

Release v0.4.0

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).

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

The repair at a glance

src/demo.unadiff
  module demo

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

Failing example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
src/demo.unauna
module demo

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

Fixed example

una.tomltoml
[package]
name = "demo"
version = "0.1.0"
edition = "0.3"
src/demo.unauna
module demo

pub tiny() -> F64 = 0.0