News for hackers. Stuff that matters.
Re:Comparing Floating-Point Numbers Is Tricky by mikeash on Thursday March 30, 2017 @07:21PM (#13999811)
It looks like numeric is a decimal type. 1/7 can't be represented exactly in either binary or decimal, so it's going to come down to rounding. It just so happens that 1/7 in binary, rounded to float precision, then multiplied by 7, is equal to 1. Do the same in decimal with whatever precision numeric gives you, and the result is not 1. I don't think there's any deep reason for it, it's just how it happens to work out. You can probably find a value where the opposite is true.

There are no comments on this comment yet.