Skip to content

num toString() output varies between Dartium and JS execution for whole number nums #4478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DartBot opened this issue Aug 13, 2012 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented Aug 13, 2012

This issue was originally filed by [email protected]


I am using Dart Editor Version 0.1.0.201208061534, Build 10315 with Dart SDK version 10311

If I use num.toString(), the output varies based on whether I am running my Dart program native (in Dartium) vs. running in FF/Chrome using the generated JS output by the Dart Editor. This variation in results only shows up for num values that have ZERO after the decimal (e.g., 10.0 - i.e., whole numbers). The JS code will truncate the ".0" in its output whereas the native Dartium output shows "10.0" as expected.

See attached test files. This seems like it will be an easy problem to resolve. thanks.


Attachments:
Dart-Num-Format-Differences-vs-JS.html (990 Bytes)
Num-Format-Test.dart (179 Bytes)

@iposva-google
Copy link
Contributor

cc @floitschG.
Added Area-Library, Triaged labels.

@floitschG
Copy link
Contributor

This is unfortunately very hard to solve. When compiling to JavaScript we currently merge integers and doubles. That is, in the JavaScript program we only have doubles.
Therefore we cannot know if 10 represents the double 10.0 or the integer 10.
When printing the number we have to guess what type the original value was, and our guess is integer. Unless we fix the integer/double merging we cannot do much better. If we printed the numbers as doubles we would get similar bug-reports for integers...
The correct number semantics is tracked in issue #1533.


Added Duplicate label.
Marked as being merged into #1533.

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report labels Aug 13, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

3 participants