Is this a bug?
1f64 * 1e-40 works, but just 1e-40 by itself causes a panic:
» 1f64 * 1e-40
0.0000000000000000000000000000000000000001 : F64
» 1e-40
panicked at 'Invalid decimal for float literal = 1e-40. This should be a type error!', crates/compiler/mono/src/ir/literal.rs:104:25
Not a bug
Needs a better error message though
1e-40
is a Frac. The default Frac is Dec. It is too small to fit in Dec.
When used with 1f64
, 1e-40
is an f64. So it fits
Would be great to file an issue on giving a good error here
Probably not a bug but the error message could be more helpful. The default type for a fractional number is Dec
which is a 128-bit fixed point (not floating point) number. I can't remember how many decimal places it can accommodate but presumably less than 40.
Oh I was answering at the same time as Brendan :big_smile:
18 places for anyone curious
Last updated: Jul 06 2025 at 12:14 UTC