Why does 0.1 + 0.2 = 0.30000000000000004?

Why does 0.1 + 0.2 = 0.30000000000000004?

Julia Evans

@b0rk wonderful post! I always struggle to explain that. Now I can point learners to your post.

Would it make sense for you to add a small mention of Python's Decimal class in the standard library as a possible workaround in certain situations?

@villares @b0rk IBM solved this on architecture level by implementing a low level Decimal Binary floating point where the operations are done on "decimal" instead of "binary". Ensure the precision, but there's an obvious storage and memory cost