Number literal syntax - allow underscores or other way to make number more readable #26845
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
closed-duplicate
Closed in favor of an existing report
type-enhancement
A request for a change that isn't a bug
This is likely a 2.x feature.
I would like to be able to use underscores inside number literals to break up long runs of digits.
For example
1000000000
is harder to understand than1_000_000_000
.Today I saw
x & 0x3FFFFFF
with a comment saying the result fits in 30 bits.If you count the
F
s, you will see there is an error, but the error has gone unnoticed for several years.If underscores were permitted, the following difference might be more apparent to the developer or reviewer:
I would want the exact placement of underscores not be prescribed, the same literal might warrant different structure depending on context. In some byte-oriented code
0x3F_FF_FF_FF
might make more sense.This feature would also make binary literals (
0b_1111_1111
= 255) more useful.The text was updated successfully, but these errors were encountered: