ABu
ABu

Reputation: 12259

Real numbers is MySQL

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

Answers (1)

O. Jones
O. Jones

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

Related Questions