One table:
items(id, price)
Has one row:
id: 1, price: 565.8
SELECT price FROM items gives 565.8
SELECT SUM(price) FROM items gives 565.799987792969 instead of 565.8 which I’d expect.
Where does the 565.799987792969 come from?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure what version you are using, but it sounds like this link describes what you are experiencing.
From the link:
Floating point numbers are stored as approximate values; if you are storing a price, you are better off using a decimal datatype which stores precise values.