Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 18311.94 in DB, when selected becomes 18311.939999

Author  Topic 

PeterG
Posting Yak Master

156 Posts

Posted - 2002-09-13 : 12:47:50
I have this field that is of a float data type. I look in the table and the value is 18311.94, but when I do a select I get 18311.939999999999. Will someone pls explain to me why this is?

MuffinMan
Posting Yak Master

107 Posts

Posted - 2002-09-13 : 13:01:35
FROM BOL:

"float and real

Approximate number data types for use with floating point numeric data. Floating point data is approximate; not all values in the data type range can be precisely represented."

Go to Top of Page

monkeybite
Posting Yak Master

152 Posts

Posted - 2002-09-13 : 13:02:08
SQL Server uses float and real data types to represent approximate numeric values. The behavior of float and real adheres to the IEEE 754 specification on numeric data types . These data types do not represent numbers as decimals; rather they use a binary approximation to store the values.

-- monkey

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-13 : 14:18:02
And if you need to maintain a precise number of decimal places with complete accuracy, use the decimal, numeric, or even the money datatypes. They are documented in Books Online with all the details of the range of values they can hold.

Go to Top of Page
   

- Advertisement -