Live data from Hacker News

1/0 = 0

hillelwayne.com

81–90 of 593 posts

Re: 1/0 = 0

#81

Earlier quoted context omitted.

It is inconsistent. If 1/0 = 0, then 1 = 0*0.

So according to you, 0*0 = 0, thus 0/0 = 0?

If division by zero is not undefined, yes. But how does this disagree with the assertion that it's mathematically inconsistent (as opposed to programmatically inconsistent)? If any case exists that leads to a logically false conclusion, then it's not logically consistent.

Re: 1/0 = 0

#82
post #28

> But is Pony doing something unsound? Absolutely not. It is totally fine to define 1/0 = 0. Nothing breaks It actually does break something, the symmetry between division and multiplication and the many pieces of code that assume that (x / y) * y equals x. Here is a naive and non practical example, but it is not impossible to find a real world example where this simplified code manifests itself accidentally or by de…

What if number types were Optionals after any operation that could result in any kind of unusual number (sqrt(-1), Infinity, NaN)? Or maybe after every operation, since any operation could overflow the type. Do any languages do that? Seems more consistent (if way more hassle) than giving a mathematically false result out of pragmatism. At least in a strictly typed language.

Zig defines checked versions of mathematical operators in its std lib [0], which return an Error Union. It's like an Optional (which Zig also has), but with an error instead of null. Your code can choose to handle this error however it wants.

[0] https://ziglang.org/documentation/master/#Standard-Library-M...

Re: 1/0 = 0

#83

Earlier quoted context omitted.

> correctly state the undefined nature of 1/0 Erm, when we say it's "undefined" we mean it literally -- standard mathematical systems of arithmetic do not define a value for that division. If you make another system of arithmetic you can define it how you want and be consistent with "regular maths" for the operations in which things are defined. It's an extension. > We have "NaN" for a reason Funnily enough, IEEE754…

> Defining it as 0 at least means floating point numbers are (presumably) closed under arithmetic operations, which could be handy. They already are closed. Floating point includes Inf and Nan for that reason. :-)

Ah, of course. Still, this definition gets you to something stricter still -- the "things that normal people think of as numbers" are closed under those operations. (Depending on what happens for overflow and 0/0, I guess.)

Re: 1/0 = 0

#84
This is "Worse is Better[1]" engineering at its most infamous. In order to make the interface consistent and simple you take the exceptional case and just make it work the same as all the other cases. It goes with the "Worse is better" credo that "it is slightly better to be simple than to be correct". Also "it is better to drop those parts of the design that deal with less common circumstances than to introduce either complexity or inconsistency in the implementation". So throwing an exception on division by zero or returning some complex thing like NaN is too much complexity, so we just return 0.

[1] https://en.wikipedia.org/wiki/Worse_is_better

Re: 1/0 = 0

#85

Earlier 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.

It is inconsistent. If 1/0 = 0, then 1 = 0*0.

This is explicitly talked about in OP about 2/3 of the way down the page. "If 1/0 = 0, then 1 = 0 * 0" is untrue. Your argument is "1/0 = 0, so multiply both sides by zero: 1/0 * 0 = 0 * 0, and then take 1/0 * 0 = 1 * 0/0." That last step isn't the case for reasons covered in the article we're ostensibly discussing.

Re: 1/0 = 0

#86
post #72

My problem with "1/0 = 0" is that it's essentially masking what's almost always a bug in your program. If you have a program that's performing divide-by-zeroes, that's almost surely something you did not intend for. It's a corner case that you failed to anticipate and plan for. And because you didn't plan for it, whatever result you get for 1/0 is almost surely a result that you wouldn't want to have returned to the…

OK but that doesn't have a lot to do with what TFA is actually talking about.

Re: 1/0 = 0

#87

Earlier quoted context omitted.

You’re doing something different than real number arithmetic. Saying 1/0 = x, and then treating x like a real number is inconsistent. But just saying “we are going to augment the real numbers with an element x that is not a real number, and then define some properties of x and prove things about it” is not.

> You’re doing something different than real number arithmetic Computer languages execute on rules that are not utilizing real number arithmetic. I didn't want to mention it, but there's these things called floats... Edit: Pony took out the "normal" version of division by zero and suggest to write a wrapper to check beforehand.

Where did I say anything about computers? I’m referring to real numbers.

Re: 1/0 = 0

#88

Unlike what the author says, this is the total opposite to a practical/pragmatic solution. He does not prove that this is a useful representation, only that given his own axioms, this can be considered mathematically correct. Very practical issues with 1/0 == 0: - This result is counter-intuitive, took building a custom fields and responding to the incredulity of all. - The main reason this is counter-intuitive is no…

Were are speaking of integers here not FP numbers.

Not to be pedantic, but one of the author's own examples involves pi inverse, so I think discussing FP numbers is valid.

Re: 1/0 = 0

#90
post #16

It's like in Ruby, when you divide 3/2 you get 1 (integer division) which is almost never the behavior you want (unless you cast all you numbers to float which is a pain to do).

When dealing with integer quantities and together with modulo, it's pretty natural. n/d gives the integer result, n%d gives the rest. n/2 for example always gives you the "middle" element. And in e.g. a loop where you e.g. transmit elements in blocks, you handle full blocks n/blocksize times, followed by a partial block with n%blocksize elements.

It's not always what you want, but it's pretty reasonable. The alternative would be if it always rounds up, which seems weirder to me. I don't think rounding to the nearest integer makes sense with integer quantities at all, that's strictly a real number operation.

Post reply on HN