So... if I do: x = a/b + c/d + e/(f*g/h) I need to check: if(b == 0 || d == 0 || f == 0 || g == 0) rather then: if(isFinite(x)) Or whatever function/equality check is appropriate, or a try/catch if it throws an exception. I have to say that using a single check on the result seems significantly less prone to bugs then having to check all the values that could produce an invalid result.
1/0 = 0
211–220 of 593 posts
Re: 1/0 = 0
#212Earlier quoted context omitted.
I guess its more flipped. How many pieces equal the whole, not how many pieces can the whole be broken up into. That's why you can't divide by 0, any number of nothing can't make a whole. *disclamer: I have no math background whatso ever
The function "division" is just like any other function. It takes two inputs, and gives an output. The reason it's a useful function is it has some properties: y=1/x is continuous except where x==0. That is, as you approach 0 from either side, it grows to either +- infinity. The developers of this language want to make this function ==0 when x is 0. You can do that, sure, but it doesn't change the fact that when you…
Re: 1/0 = 0
#213Earlier quoted context omitted.
We will be introducing two sets of integer math operators in Pony. The current which are non-partial and can over/underflow + division by zero == 0 AND new ones that will be partial functions that cause an error on under/overflow and division by zero.
> new ones that will be partial functions that cause an error on under/overflow and division by zero. A "strict" mode is usually always an afterthought once we have errors & people run it in strict mode and facepalm. One of the first "utilities" I wrote for PHP was something called "pecl/scream", which turned off all the "unchecked" operations across the whole VM. And in general, this works out poorly for code qualit…
Re: 1/0 = 0
#214Re: 1/0 = 0
#215Re: 1/0 = 0
#2161/0 = +infinity; 1/+infinity = 0; simple.
Re: 1/0 = 0
#217Re: 1/0 = 0
#218Re: 1/0 = 0
#219Hi, 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…
Having 1/0 = 0 and 1.0f / 0.0f = +inf makes sense in two applications I can think of. The first would be currency systems in which prices down to the pre-determined fractional component are represented as unsigned integers. In calculating margin requirements division by zero equating to zero would be the correct answer. And two, for double precision continuous variables, any application involving 3D geometrical trans…
Re: 1/0 = 0
#220Earlier quoted context omitted.
I'm curious, what do you think about Julia's approach with its special "missing" value? Does this approach make sense outside the context of data analysis? https://julialang.org/blog/2018/06/missing
I can't really comment. I don't know how they are doing it and why they made that choice. I assume that Julia was already boxing integers in some fashion at which point this 100% makes sense to me. Also, given the performance profile that you are seeking to allow programmers to achieve, I think boxing all integers makes sense, then you can give folks protection from integer overflow and underflow and otherwise make h…
Apparently this can work well with SIMD instructions.