Error codes

E0280: format precision on a type without one

In a terminal: auk explain E0280 prints this page.

On this page

In "{x:.2}", the precision .2 means "2 decimal places" for a float or "at most 2 chars" for a str. It means nothing for other types such as int.

Wrong#

auk
fn show(n: int): str = "{n:.2}"

Fixed#

auk
fn show(n: int): str = "{float(n):.2}"

Common causes#

  • Formatting an int as if it were a float: convert with float(n).
  • Padding was meant instead: {n:>5} pads to width 5.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page