Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDivision by zero mathematical inconsistencies #932
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Dec 28, 2017
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Dec 28, 2017
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bitamar
Dec 29, 2017
Hi @fcabouat,
I don't find it inconsistent - Division by zero is either infinity, or -infinity, so if "-0" is the same as 0, that's the expected result. I.e -1 / 0 is -Infinity and 1 / 0 is Infinity.
bitamar
commented
Dec 29, 2017
•
|
Hi @fcabouat, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fcabouat
Dec 29, 2017
-(1 / x) == -1 / x == 1 / -x for every x != 0. Breaking that rule for x = 0 is indeed an inconsistency.
At least in real numbers space dividing by zero is a mathematical error / is undefined. It's not equal to Infinity or -Infinity. Otherwise, it would lead to -Infinity == Infinity. Is it what you're proposing ?
What about Elm's policy of making errors explicit / forcing the programmer to handle those errors in a type safe way ?
fcabouat
commented
Dec 29, 2017
|
-(1 / x) == -1 / x == 1 / -x for every x != 0. Breaking that rule for x = 0 is indeed an inconsistency. At least in real numbers space dividing by zero is a mathematical error / is undefined. It's not equal to Infinity or -Infinity. Otherwise, it would lead to -Infinity == Infinity. Is it what you're proposing ? What about Elm's policy of making errors explicit / forcing the programmer to handle those errors in a type safe way ? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fcabouat
Feb 11, 2018
After some research, it appears I'm not the only one to cringe about this mathematical inconsistency.
Anyway, since the same behavior can be seen in Haskell & al and has been standardized in IEEE 754, I guess t wouldn't be much wiser to go against the standard.
Leaving https://stackoverflow.com/questions/9354016/division-by-zero-in-haskell as a reference and closing the issue.
fcabouat
commented
Feb 11, 2018
|
After some research, it appears I'm not the only one to cringe about this mathematical inconsistency. Leaving https://stackoverflow.com/questions/9354016/division-by-zero-in-haskell as a reference and closing the issue. |
fcabouat commentedDec 28, 2017
Hi,
In Elm repl I get :
Which is a bit weird mathematically and comes from the fact that 1 / 0 gives Infinity where it should (imho) give NaN.
cheers,
François