There’s some special floating point values that you should be aware of. Zero, infinity, and not a number are three cases that might surprise you.

Let’s get started. First of all, do you know the sign of zero? Is it positive or negative?

Depending on your country and traditions, zero might either have no sign or be both positive and negative. I think it’s standard for most places that zero has no sign at all. It can be important when a value approaches zero to consider what direction it’s approaching from. In other words, is a value shrinking from a positive value towards zero? Or is it increasing from a negative value towards zero? Once a value reaches zero, then it loses it’s sign. Or it gains both signs if you prefer. The main point is that zero behaves slightly differently than all other values.

This difference is most important when dividing. Listen to the full episode for more information about how dividing by a floating point 0.0 is very different than dividing by an integer 0 value. Floating point division can lead to infinity while integer division can lead to almost anything. And from there, it’s not too hard to get into “not a number” values.