Want to divide by zero?

The world doesn't want you to do it.

Officially you can't do this. That's what you've been told. That's what you learned in school. That's what almost everybody says...

Almost... ?

It turns out that in some programming languages, you can divide by zero! JavaScript allows us to do this. The result of X/0 will be positive Infinity for X>0 and negative Infinity for X<0. But what about 0/0? Well, this will yield "NaN" which stands for Not a Number. So while JS allows you to divide any number other than zero by zero, it still doesn't allow you to divide zero by zero :(

That was fun, but I wanted to divide zero by zero! Is there another language which allows us to do that?

Yes, there's a language called Pony, and it's said to allow division by zero. Ok, that was a good news, but I didn't know Pony, so I had to learn it (I suggest you do the same). It turns out in Pony you can do other weird things. Like what does "a = 1" return? Answer: the old value of a. Seems weird, it's actually not.

Back to my mission, I realized that you still can't do "0/0", since division by the 0 constant is not allowed. So I had to trick the compiler that I'm dividing zero by some other variable (which I set to 0). And it worked!!! I learned that in Pony, zero divided by zero is zero!. Here is the code in Pony, which you can run in your browser: https://playground.ponylang.org/?gist=032401a70be91e6a96ebea3d70cd3e8e

And that's it!

Now you can divide by zero. Enjoy :)