Skip to content
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

VM: double.parse creates NaN value not identical to double.NAN. #15293

Closed
lrhn opened this issue Nov 25, 2013 · 4 comments
Closed

VM: double.parse creates NaN value not identical to double.NAN. #15293

lrhn opened this issue Nov 25, 2013 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-as-intended Closed as the reported issue is expected behavior

Comments

@lrhn
Copy link
Member

lrhn commented Nov 25, 2013

Example code:
main() {
  print(identical(double.NAN, double.parse("NAN")));
}

prints "false", should print "true".

I'm adding a hack to prevent this problem, in double_patch.dart,
adding the line:
  if (result.isNaN) return NAN;

That's a workaround, but the underlying identical operation should not make this necessary, and it suggests that it may happen in other places too.
See: https://codereview.chromium.org/85633003/diff/50001/runtime/lib/double_patch.dart

@ghost
Copy link

ghost commented Nov 25, 2013

Set owner to @sgmitrovic.
Added Accepted label.

@iposva-google
Copy link
Contributor

After some discussion we are not sure that identical for Nan and -Nan is expected and desired. Similarly are two Nan values with a different bit pattern identical?


cc @sgmitrovic.
Set owner to @floitschG.
Added NeedsInfo label.

@lrhn
Copy link
Member Author

lrhn commented Nov 26, 2013

From the spec (section: Object Identity):

"The predefined dart function identical() is defined such that identical(c1, c2) iff:
  ...
  c1 and c2 are instances of double and one of the following holds:
     ...
     Both c1 and c2 represent a NaN value."

So all NaN values need to be identical.

@floitschG
Copy link
Contributor

I filed issue #15317.

Closing this issue as designed.


Added AsDesigned label.

@lrhn lrhn added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-as-intended Closed as the reported issue is expected behavior labels Nov 26, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-as-intended Closed as the reported issue is expected behavior
Projects
None yet
Development

No branches or pull requests

4 participants