3 ms·
I must admit I prefer 1/0 not to be 0 in the "Common Algebra". But that might be because I come more from an Natural Science/Engineering background where contin
by blablabla123 8y ago
I must admit I prefer 1/0 not to be 0 in the "Common Algebra". But that might be because I come more from an Natural Science/Engineering background where continuity is something that is expected virtually everywhere. Not even Theoretical Physics text books mention that continuity of functions is required as it is so ubiquitous. 1/0000000.1=10000000, 1/0.00000001=100000000.0, ..., 1/0=0 would break that. In fact we have even harder requirements usually we want everything at least twice differentiable...
However, nobody stops people from defining their own Algebras or Fields on languages that support it. On C++ this should be a no-brainer, if the sentiments of the article is true that consistency is no problems. Being a "man of industry" myself, 1/0 throwing or at least becoming infinity doesn't seem a problem to me. Similar to not using gotos or so.
FWIW, JavaScript an underrated language when it comes to weird corner-cases does the right thing. It doesn't throw an error, instead the result becomes Infinity. When I multiply it with a finite number it stays Infinity. When I multiply it with 0 it becomes NaN which is totally sound because in a real-world application one could come to these numbers because of limitations of the storage. 0.00000......1 becomes 0 thus the real result of 1/0 x 0 in that case can indeed be literally everything. The beautiful thing about JavaScript is how it continues to handle this, when I say 1 < NaN or 1 > NaN it stays false. So the algorithms are likely to fail much more graceful than in other languages.
- lucian1900 8y agoJavaScript’s behaviour is just how floats work. They are the same in all languages. There is storage reserved as part of their representation to encode infinity and NaN. The issue here is hardware integers, which have no signalling bits beyond possibly sign.
- blablabla123 8y agoSure, JavaScript uses floats for everything. But the article seems to be actually mostly about real numbers: "The real numbers, along with our conventional notion of addition and multiplication, form a field." (Ignoring the fact that there are finite fields that are properly closed under all operations)