Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Which languages would those be?


  $ python3
  Python 3.9.1 (default, Feb  3 2021, 07:04:15)
  [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> 10 / 0
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ZeroDivisionError: division by zero
  >>>


Although Python seems to be the exception to the rule here, your example isn't exactly right. In your example, you're performing integer division, not floating point division. In most languages, integer division by zero is indeed some kind of exception (or UB, which will most likely result in a hardware exception, causing a signal sent to the process). However, floating point division by zero is well-defined, as per definition of floating point arithmetic (in some RFCs), and most languages don't throw exceptions in this case. Python indeed seems to be the exception to the rule.


In Python 3, 1/0 is floating point division. 1//0 would be integer division.


Right, Python2 is still the default on Debian, so I didn't notice.


I guess I'm thinking of Python mostly. I thought OCaml did as well but apparently not.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: