Reputation: 12259
Should I take precaution when comparing real numbers in MySQL?
# Get completly paid bills
select * from bills left join payments on bills.id = payments.bill
where bills.price = payments.price;
In usual programming languages (like C/C++), such comparisions between real numbers (floats) must be done using a delta
value acting as comparision precision:
if (abs(bill_price - payments_bill) < 0.00001) // do something
But I don't know if MySQL has such precision problems.
Upvotes: 2
Views: 359
Reputation: 108641
MySQL's internal floating point format is 64-bit IEEE.
Yes, you need to worry about machine epsilon (roundoff errors) when doing that kind of arithmetic in MySQL.
Upvotes: 1