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

Not-a-numbers do not always follow IEEE semantics #2314

Open
jcbrinfo opened this issue Sep 19, 2016 · 1 comment
Open

Not-a-numbers do not always follow IEEE semantics #2314

jcbrinfo opened this issue Sep 19, 2016 · 1 comment
Labels

Comments

@jcbrinfo
Copy link
Contributor

$ ../bin/nit -e '
> print(0.0/0.0 != 0.0/0.0)
> var x = 0.0/0.0
> print(x.is_nan)
> print(x != x)
> print(x != x * 1.0)'
true
true
false
true
@privat privat added the bug label Dec 6, 2016
@privat
Copy link
Member

privat commented Dec 6, 2016

Yeah, there is a choice to make here. Either Object::== is the opposite of Object::!= and does not contradict Object::is_same_instance, that are some strong laws needed by a lot of data-structures and algorithms, either we follow the crappy IEEE semantic on NaN.

By the way, other OO language seems have such a hard time. Even Java https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#equals(java.lang.Object)

Nevertheless, consistency need to be achieved in Nit. The underlying problem here seems that == and != are implemented by something like: compare the instance boxe addresses, if different do a == in C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants