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 2008 Forums
 Transact-SQL (2008)
 Query Output

Author  Topic 

sqldba20
Posting Yak Master

183 Posts

Posted - 2011-03-14 : 11:29:16
Folks:

I have a column 'Rate' as Float and which has a value as 0.035. When I run the following the query The 'Delta' returns a 0 whereas the 'MultiDelta' returns a differcent number as '4.44089209850063E-16'
Any reason what am I doing wrong here?

select Rate - 0.035 as Delta, Rate*100-3.5 as MultiDelta


Thanks !

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-14 : 11:36:18

declare @rate float
set @rate=0.035
select @rate - 0.035 as Delta, cast(@rate*100 as decimal(12,2))-3.5 as MultiDelta


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqldba20
Posting Yak Master

183 Posts

Posted - 2011-03-14 : 11:47:55
Any reason why I have to cast it as decimal when the value is stored as float?


Thanks !

quote:
Originally posted by madhivanan


declare @rate float
set @rate=0.035
select @rate - 0.035 as Delta, cast(@rate*100 as decimal(12,2))-3.5 as MultiDelta


Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-15 : 10:05:26
Read about float datatype in SQL Server help file.

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -