I saw this Reddit post today saying "My son's third-grade teacher taught my son that 1 divided by 0 is 0. I wrote her an email to tell her that it is not 0. ...
I’m not super great at math, and the concept of division by zero has been somewhat confusing for me. It’s also been a bane to my existence as a programmer. To me, in both scenarios, it makes sense to get back the original number, because 0 equal parts and zero inches wide leaves the original pizza untouched. But I also accept that there are much smarter folks out there who know better than I do, so undefined or NaN is what it is.
To me, in both scenarios, it makes sense to get back the original number, because 0 equal parts and zero inches wide leaves the original pizza untouched
To illustrate why it’s not the original number, ask yourself this question — “How many times can you slice a pizza such that each slice is 0 inches wide?”
Yes, you’re leaving the pizza untouched with each slice, so you will never stop slicing. Or, you will say zero, because slices that are 0 inches wide are not slices at all. Or you’ll just say it can’t be done.
I’m not super great at math, and the concept of division by zero has been somewhat confusing for me. It’s also been a bane to my existence as a programmer. To me, in both scenarios, it makes sense to get back the original number, because 0 equal parts and zero inches wide leaves the original pizza untouched. But I also accept that there are much smarter folks out there who know better than I do, so
undefined
orNaN
is what it is.Thanks though for explaining it!
To illustrate why it’s not the original number, ask yourself this question — “How many times can you slice a pizza such that each slice is 0 inches wide?”
Yes, you’re leaving the pizza untouched with each slice, so you will never stop slicing. Or, you will say zero, because slices that are 0 inches wide are not slices at all. Or you’ll just say it can’t be done.