I have noticed when working in SQL Server that the values I store in column type REAL get changed. For example if I store a value of 32.54, it returns a value of 32.53999878999. Does anyone know why this happens?
One thought on “What is the difference between Floating Point, Money and Real types in MS SQL Server?”
Comments are closed.
Hi, the reason for this effect is due to the fact that floating point numbers in a computer are not represented by decimal fractions but are represented as Binary fractions. Because the numbers are represented as binary fractions there is some rounding that happens because most fractional numbers do not have an exact mapping to a binary fraction. When this binary fraction is translated back into a decimal fraction, you get a slightly different value due to rounding errors.
In SQL Server database the money values are stored as a decimal type which stores the exact decimal digits you entered. This format avoids the decimal rounding errors, however this format is also a little less efficient for the computer to deal with.