Why does 0.1 + 0.4 = 0.5?
问题 We know that floating point is broken, because decimal numbers can't always be perfectly represented in binary. They're rounded to a number that can be represented in binary; sometimes that number is higher, and sometimes it's lower. In this case using the ubiquitous IEEE 754 double format both 0.1 and 0.4 round higher: 0.1 = 0.1000000000000000055511151231257827021181583404541015625 0.4 = 0.40000000000000002220446049250313080847263336181640625 Since both of these numbers are high, you'd