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
Unexpected behavior of Int#/ on zero division #9707
Comments
That's expected. Check out Ruby (or any language for that matter):
In Ruby, |
You are right. There are even specs for that. Although, it is my fault that I did not check it before, Python, Golang and probably other languages raise an exception on both cases: Python:
Shouldn't Crystal do the same? |
I don't know |
I don't think so. Infinity and NaN are valid values of float. |
They are valid, but I would say it's rather confusing. I don't see any cases (apart from following standards, which, despite everything, some languages break) where Infinity would make more sense than an exception. On the other hand, I can imagine situations where throwing an exception would result in cleaner and more consistent code. I do not insist on my position, but the current behavior seems a bit wrong to me. |
Int#/
andInt#//
produce different output when divided by zero:crystal --version
:The text was updated successfully, but these errors were encountered: