X Tutup
The Wayback Machine - https://web.archive.org/web/20201109225801/https://github.com/processing/processing-docs/issues/805
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

Equality operator fails with NaN #805

Open
Achimoto opened this issue Mar 25, 2020 · 4 comments
Open

Equality operator fails with NaN #805

Achimoto opened this issue Mar 25, 2020 · 4 comments
Assignees

Comments

@Achimoto
Copy link

@Achimoto Achimoto commented Mar 25, 2020

Issue description

"==" operator fail with NaN confuses beginners

float result = float(s); // String s = "something wrong"
println(result); // prints NaN
if (result == Float.NaN) throw new Exception("Float error"); // does not throw exception

Proposed fix

maybe add correct syntax proposal (Float.isNaN) to language description, section Equality

@benfry
Copy link
Member

@benfry benfry commented Apr 30, 2020

Hm, maybe we need to add a NaN page to equality, since that's what would be seen in the console… (Not sure of a better place and also concerned that people would actually find it.) In that page we could mention testing a variable against itself if (x != x) and Float.isNan(x) as ways to test for NaN, and x == x as a way to verify not NaN.

Though any “beginner” who knows Float.NaN probably also knows Float.isNaN() and its use. :)

@Achimoto
Copy link
Author

@Achimoto Achimoto commented Apr 30, 2020

@REAS
Copy link
Member

@REAS REAS commented Jun 3, 2020

I'm wondering how common it is for beginners to see NaN and how it happens. I think some examples would help. It doesn't feel right to "bury" it inside the equality reference page (https://processing.org/reference/equality.html), but maybe that's right? What about NaN having it's own page?

@REAS REAS self-assigned this Jun 3, 2020
@jeremydouglass
Copy link
Contributor

@jeremydouglass jeremydouglass commented Jun 3, 2020

What about NaN having it's own page?

That would make it easy to add a "see also" reference from the equality page -- and from anywhere else needed.

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.
X Tutup