249: GameDev: Floating Point: Zero, Infinity, NaN.
Listen now
Description
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.
More Episodes
This is the first in a series of comments about the book “How To Code C++ From a Simple Idea To a Game You’ll Understand!” Each episode will be short and focused. You can watch the video versions on YouTube at https://www.youtube.com/channel/UC4K_WBflLr2Cz0Sje_xTXkA You can also get your own copy...
Published 01/28/22
This is an interview with Conor Hoekstra about C++ algorithms and ranges. Conor presented my favorite talk at CppCon 2019 called Algorithm Intuition. I asked him to talk about algorithms on this podcast and he agreed. This just proves again why CppCon is the best place to be when you want to...
Published 09/25/19
Published 09/25/19