E0103Float literal out of range for
Error
Float literal out of range for f64
ErrorA float literal must round to a finite f64, which holds magnitudes up to about 1.8e308. 1e400 rounds to infinity and is an error.
Why
A literal is rounded to the nearest f64, and no f64 is near 1e400. Silently turning it into infinity would hide a typo, so the literal is an error. A literal below the smallest f64, such as 1e-400, rounds to zero and is not an error. The compiler does not invent a value, so there is no fix.
Broken
fn main() {
let x = 1e400
print(x)
}
What sisu says
error[E0103]: literal out of range for `f64` --> E0103.sisu:2:13 | 2 | let x = 1e400 | ^^^^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0103
Fixed
fn main() {
let x = 1e300
print(x)
}
Sisu