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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Float Error?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

7 Posts

Posted - 05/13/2013 :  01:01:40  Show Profile  Reply with Quote
Hi all!
My code:
declare @f1 float, @f2 float, @f float;
select @f1 = 0.3, @f2 = 0.3
set @f = @f1 + @f2
select @f +=@f1
select @f = @f -0.9
select @f
result @f:
why @f not = 0?
How to do @f = 0?

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 05/13/2013 :  01:14:02  Show Profile  Reply with Quote
You can use dec(p,s) data type for this kind of arithmetic calculations

refer this link to know the reason behind the above result

Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 05/13/2013 :  01:18:30  Show Profile  Reply with Quote
float and real are only approximate numerical data types. so they actually precision may differ from what you see. SO if you want to deal with accurate numeric data use decimal or numeric

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000