docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

本頁尚未翻譯,以下為英文原文。

#E0004: literal out of range for its type

A literal does not fit its type: 300u8, -1 where an unsigned type is expected, or a float too large for f32. Use a wider type (300u16), a value that fits, or an int for a number of any size.

nabi
let b: u8 = 300;
error[E0004]: integer literal `300` out of range for `u8`
  --> main.nabi:1:13
   |
 1 | let b: u8 = 300;
   |             ^^^

Use a type wide enough for the value:

nabi
let b: u16 = 300;
println(f"{b}");
300

Related: E0003 malformed numeric literal, E0040 mismatched types

Found a mistake? Edit this page on GitHub. Last updated