-
Notifications
You must be signed in to change notification settings - Fork 98
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
ValidationUtils.isNonnegativeInteger returns true for -0 #47
Comments
I didn't know about signed 0 until today. Where can we meet it? |
@tonyofbyteball https://stackoverflow.com/questions/7223359/are-0-and-0-the-same It's part of The main difference in practical terms is when dividing or multiplying by zero as:
Of course, dividing anything by zero is problematic for other reasons anyway... JS also returns The reason it is coming up at all is because JS doesn't actually have an explicit integer number type, as it uses doubles for everything. Even after ES6 introduced As a comparison, here is the output from my REPL in clojure (using the JVM which has both floats and integer number types):
You can see there is a difference between signed 0 in doubles but dividing by integer 0 is always an exception as there isn't an integer negative zero AFAIK. IMO the JVM behaviour of integers is usually what you want, dividing by the integer 0 is undefined in normal arithmetic and throwing an error is more helpful than returning |
So yeah... tbh it could go either way... Argument for: There is no difference between the integer represented by both Argument against: JavaScript does not have any integers in reality, so following |
Just something I came across while working on #46 - i'm not sure if this is desired behaviour or not
The text was updated successfully, but these errors were encountered: