1/0 = 0
401–410 of 593 posts
Re: 1/0 = 0
#402Earlier quoted context omitted.
My comment from when this came up on Reddit, slightly edited for context: `/`-by-0 is just an operation and it tautologically has the semantics assigned to it. The question is whether the specific behaviour will cause bugs, and on glance that doesn't sound like it would be the case. Principally, division is normally (best guess) used in cases where the divisor obviously cannot be zero; cases like division by constant…
What happens for 0 / 0? Is this also 0?
Re: 1/0 = 0
#403Earlier quoted context omitted.
> He refutes them by asserting that the multiplicative inverse doesn't exist. Yes - but in algebraic fields division by x is equivalent to multiplication by 1/ x . This is precisely why you cannot have a field that admits division by 0: because 0 has no multiplicative inverse.
Maybe all this talk about fields is a distraction? Integer arithmetic isn't a field anyway. Other than 1 and -1, no integer has a multiplicative inverse that's an integer. Integer division just isn't the same operation as division on rationals or reals. The same laws don't apply. (For floats, division by zero can return Inf, -Inf or NaN and there's no reason to define it differently.) It looks like the theorem-provin…
Re: 1/0 = 0
#404Earlier quoted context omitted.
You are correct. But it really should be NaN, since 1/ε is positive infinity, whereas 1/-ε is negative infinity. Oh well :)
JS just assumes the limit direction for you, so 1/0 is Infinity, but -1/0 is -Infinity. 0/0 at least is correctly NaN. (Edit: And I just verified against my memory, Matlab (or at least Octave) does the same thing. While Matlab might get characterized as being for the ivory tower, at least it's had a long history of being used for practical math applications within the tower. Edit2: And anyway this is the defined beha…
Re: 1/0 = 0
#405Hi, I'm on the Pony core team. I will be writing in more detail about this decision. A few short notes until then: 1) no one on the team has ever been happy with ending up here, understanding why the decision was made involved understand how partial functions (one that can produce errors like division by zero) are handled in Pony and interesting ergonomic issues that can result that is a large part of what my post wi…
Re: 1/0 = 0
#406Earlier quoted context omitted.
My comment from when this came up on Reddit, slightly edited for context: `/`-by-0 is just an operation and it tautologically has the semantics assigned to it. The question is whether the specific behaviour will cause bugs, and on glance that doesn't sound like it would be the case. Principally, division is normally (best guess) used in cases where the divisor obviously cannot be zero; cases like division by constant…
What happens for 0 / 0? Is this also 0?
Re: 1/0 = 0
#407Earlier quoted context omitted.
To clarify, in Javascript 1/0 is Infinity, not NaN.
You are correct. But it really should be NaN, since 1/ε is positive infinity, whereas 1/-ε is negative infinity. Oh well :)
So 1/0 is infinity, and 1/-0 is -infinity.
Re: 1/0 = 0
#408Earlier quoted context omitted.
Hillel is talking about math. Unfortunately computers don't really do "math". For example, math doesn't have overflow and underflow to deal with. The floating point standard says that division by 0.0 should be Infinity and provides a value for it. The integer math, all possible values are used for numbers, so division by zero is undefined behavior. And from there, every language is potentially going to have a mess of…
Integers are perfectly fine in math. But they are not a field. Integers modulo something are also well understood in math - but again not a field.
Re: 1/0 = 0
#409My math is rusty but 1 / 0 := 0 implies that 0 * 0 := 1. This contradicts the definition of a binary field [1], let alone a field of real numbers. [1] https://en.wikipedia.org/wiki/GF(2) > "It is totally fine to define 1/0 = 0." No, it's not, at least not useful. If you define it that way, you will not have a field . Then you don't have +, -, *, and / operations with the commonly assumed behavior. However, it is defi…
> However, it is definitely possible to define some operation such that 1 `op` 0 := 0, just not the inverse operation of multiplication. If you read the post this is actually exactly what the OP is saying.
I, for one, will respectfully decline to use any programming language that defines 1/0 to be 0.
Re: 1/0 = 0
#410Earlier quoted context omitted.
I think OP means that nothing breaks mathematically. It is not inconsistent and not false, so you can work with it. The only issue is to deal specially with the case of division by zero, which you have to do anyways. Code that assumes that (x/y) * y = x is wrong if you don't check for y = 0, independently of what you define x/0 to be.
You do realize that division is the inverse operation of multiplication, right? Like subtraction is the inverse of addition. By defining addition we define subtraction. By defining multiplication we define division. This is where the author fails. Division is multiplication of a fractional value. This is VERY important. And just because it is mathematically a field does not mean it is particularly the right choice. A…
There are legitimate reasons to advocate for defining division by 0 in the context of a programming language. But the attempt at mathematical rigor really distracts from those reasons. It feels like the author made a decision and reached for some odd mathematics that seems to support it but doesn't. Floating numbers don't even form a field. If we define division by 0 in a field it stops being a field and becomes a ring or some sort of weird finite field with a single element...