Re:Haskell: The Bad Parts, part 2 (2020)
by yakubin on Tuesday February 09, 2021 @11:24PM
(#26085738)
Which languages would those be?
[ Parent
| on HN ]
Re:Haskell: The Bad Parts, part 2 (2020)
by warkdarrior on Wednesday February 10, 2021 @12:26PM
(#26092089)
$ 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
>>>
Re:Haskell: The Bad Parts, part 2 (2020)
by yakubin on Wednesday February 10, 2021 @09:45PM
(#26097660)
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.
Re:Haskell: The Bad Parts, part 2 (2020)
by dthul on Thursday February 11, 2021 @09:28AM
(#26101791)
In Python 3, 1/0 is floating point division. 1//0 would be integer division.