dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.21k stars 1.57k forks source link

Dart2js int.toRadixString(10) uses exponential notation for larger numbers. #22046

Open lrhn opened 9 years ago

lrhn commented 9 years ago

JavaScript Number.toString with radix-argument 10 will use exponential notation for numbers larger than ~1e20. Dart2s uses toString(radix) for its toRadixString, giving a result which can not be parsed back using int.parse. For integers (and toRadixString only exists on int), it should write an integer literal, not a double literal.

lrhn commented 1 month ago

(It may be possible to use .toLocaleString("en-us", {useGrouping: false}) for values >= 1e21.)