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
 General SQL Server Forums
 New to SQL Server Programming
 Real data type parse ?

Author  Topic 

weipublic
Starting Member

19 Posts

Posted - 2010-03-08 : 14:37:32
Hi All,

For following, I wanted to get a result of '-163773.58', but I actually got '-163774'.

Can any one help me?

Thanks in advance!!!


DECLARE @REAL1 REAL
SET @REAL1 = -163773.58
DECLARE @REAL REAL
SET @REAL = @REAL1
PRINT @REAL

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-03-08 : 22:15:13
Real and float datatypes are approximates, and you will encounter this kind of issue when you use them. If you require strict precision you must use a decimal or numeric datatype.
Go to Top of Page

weipublic
Starting Member

19 Posts

Posted - 2010-03-09 : 11:40:00
Thank you so much for your help!

Go to Top of Page
   

- Advertisement -