May 2008
12 posts
2 tags
2 tags
2 tags
2 tags
2 tags
Why does ROUND(9.95,1) return 9.9 instead of 10.0?...
SQLite uses binary arithmetic and in binary, there is no way to write 9.95 in a finite number of bits. The closest you can get to 9.95 in a 64-bit IEEE float (which is what SQLite uses) is 9.949999999999999289457264239899814128875732421875. So when you type “9.95”, SQLite really understands the number to be the much longer value shown above. And that value rounds down. This kind of...