#3228 - Day Counter

@xkcd floating point numbers are so wild in how they completely undermine the idea that computers are precision machines.

Don't get me wrong, they absolutely are but it's an interesting juxtaposition that one of the key building blocks of many classes of programs relies of what amounts to approximate math.

@renardboy @xkcd The trouble is, as soon as you need to represent sonething that's not a rational number, you're pretty much forced to use an approximation of some sort.

@me @xkcd Fun fact: there's actually even more to it than that. Plenty of rational numbers *cannot* be represented exactly in binary. Check out this online tool and try converting simple decimals like 0.1 or anything that isn't a multiple of a negative power of two: https://www.rapidtables.com/convert/number/decimal-to-binary.html

(I hope this doesn't come across as mansplaining, I just want to share something I find fascinating for the benefit of anyone who might also find it interesting)

Decimal to Binary Converter

Decimal number to binary conversion calculator and how to convert.

@renardboy It can be done, just not with a floating point data structure. Many languages have a rational data type... just not all, and it could be implemented in the ones that don't. It's just more computationally expensive, and often deemed not to be worth it.