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…
I almost want two different division operations: One where 1/0 = 0, exclusively for use in progress bars and stuff like that, and another one for everything else. Because frequently division by zero indicates a bug. But similarly frequently, I end up crapping out annoying little bits of code like if (foo == 0): return 0 else: return bar / foo
1/0 = 0
131–140 of 593 posts
Re: 1/0 = 0
#132 1.0 / 0
=> Float::INFINITY
and 0 * Float::INFINITY
=> Float::NAN
I think infinity is a more intuitive result, but most of the time i get this as a user i would rather see 0 (bought books per month: Infinity). As a programmer i like to get an error, because i forgot to handle an edge case...Re: 1/0 = 0
#133My 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…
I almost want two different division operations: One where 1/0 = 0, exclusively for use in progress bars and stuff like that, and another one for everything else. Because frequently division by zero indicates a bug. But similarly frequently, I end up crapping out annoying little bits of code like if (foo == 0): return 0 else: return bar / foo
Isn't this reason the the point of having a utils library with commonly used pieces of code?
Re: 1/0 = 0
#134> 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…
> (x / y) * y equals x Even without Pony's assumption, that's only true when y != 0.
Re: 1/0 = 0
#135My 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…
Re: 1/0 = 0
#136Unlike 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…
I think this is calling for a Pony programmer working with floating point to know how their own basic operators function. Wrapping division in a function that checks for zero will give you the proper result you would like to return.
Re: 1/0 = 0
#137Unlike 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…
That’s the opposite of what happened. A value overflowed, which triggered an exception, which caused a module to emit diagnostic information, which was misinterpreted by other systems as flight data. Interestingly, the value which overflowed was part of a system which was only used until LT+7, which had aleady passed…
In short, if the overflow had simply saturated or wrapped around to 0 or given some other garbage result, the Ariane would have not crashed.
Re: 1/0 = 0
#138Re: 1/0 = 0
#139> But is Pony doing something unsound? Absolutely not. It is totally fine to define 1/0 = 0. Nothing breaks a=x/N b=y/N If a==b, then x==y No longer true, with this change. Essentially a variety of mathematical properties of numbers in the Real space don't hold when you allow division by 0.
This is not true if you say division by 0 is undefined or +inf either. It really is totally fine.
Many languages handle this in a practical way by creating a special value "undefined", "NaN", or others that has special properties. But let's be clear that "0" is a normal number in the real number space, as so expectations about properties of real numbers are not going to hold up.