Please start any new threads on our new site at http://forums.sqlteam.com. 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
 All Forums  SQL Server 2005 Forums  Transact-SQL (2005)  FLOAT datatype Reply to Topic  Printer Friendly
Author  Topic

aprichard
Yak Posting Veteran

India
62 Posts

 Posted - 04/16/2009 :  09:16:00 Can any one of you explain drawback of float type.

SwePeso
Patron Saint of Lost Yaks

Sweden
30421 Posts

 Posted - 04/16/2009 :  09:33:31 It's inprecise for decimals. Integer part will work ok.It uses a binary storing algorithm due to the IEEE-754 standard it uses.E 12°55'05.63"N 56°04'39.26"

SwePeso
Patron Saint of Lost Yaks

Sweden
30421 Posts

 Posted - 04/16/2009 :  09:45:11 The reason is that the decimal part must be represented in the way(bit1 / 2^1) + (bit2 / 2^2) + (bit3 / 2^3) + (bit4 / 2^4) + ...(bit1 / 2) + (bit2 / 4) + (bit3 / 8) + (bit4 / 16) + ...If you sum all these combinations to infinity the sum is exactly 1, which means in theory all possible decimal values can be used and represented.However IEEE754 says only 52 bits can be used for decimals. So smallest value is 1 / 2^52 (roughly 2.22044604925031E-16)and all possible values to store are multiples of this smallest possible value.E 12°55'05.63"N 56°04'39.26" Edited by - SwePeso on 04/16/2009 09:51:29

Transact Charlie
Flowing Fount of Yak Knowledge

United Kingdom
3451 Posts

 Posted - 04/16/2009 :  10:50:57 [everything Peso said] = rounding errors!compare FLOAT and DECIMAL / NUMERIC in books on lineCharlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION

SwePeso
Patron Saint of Lost Yaks

Sweden
30421 Posts

 Posted - 06/28/2013 :  04:45:38 And what is also important, if you restore your database containing a FLOAT, the value might differ if the new server has another kind of processor.N 56°04'39.26"E 12°55'05.63"

michael.appleton
Posting Yak Master

United Kingdom
160 Posts

 Posted - 06/28/2013 :  05:21:59 I think an easy to imagine a floating point number is usually a very good approximation of a number. It you need something to be exact, don't use a floating point number. Edited by - michael.appleton on 06/28/2013 05:22:53
Topic
 Reply to Topic  Printer Friendly Jump To: Select Forum General SQL Server Forums       New to SQL Server Programming       New to SQL Server Administration       Script Library       Data Corruption Issues       Database Design and Application Architecture SQL Server 2012 Forums       Transact-SQL (2012)       SQL Server Administration (2012)       SSIS and Import/Export (2012)       Analysis Server and Reporting Services (2012)       Replication (2012)       Availability Groups and DR (2012)       Other SQL Server 2012 Topics SQL Server 2008 Forums       Transact-SQL (2008)       SQL Server Administration (2008)       SSIS and Import/Export (2008)       High Availability (2008)       Replication (2008)       Analysis Server and Reporting Services (2008)       Other SQL Server 2008 Topics SQL Server 2005 Forums       Transact-SQL (2005)       SQL Server Administration (2005)       .NET Inside SQL Server (2005)       SSIS and Import/Export (2005)       Service Broker (2005)       Replication (2005)       High Availability (2005)       Analysis Server and Reporting Services (2005)       Express Edition and Compact Edition (2005)       Other SQL Server Topics (2005) SQL Server 2000 Forums       SQL Server Development (2000)       SQL Server Administration (2000)       Import/Export (DTS) and Replication (2000)       Transact-SQL (2000)       Analysis Services (2000)       MSDE (2000) Development Tools       ASP.NET       Reporting Services Development       Other Development Tools Site Related Forums       Site Related Discussions       Article Discussion       Poll Discussion       The Yak Corral Other Forums       SQL Server 6.5 \ SQL Server 7.0       Other Topics       MS Access       ClearTrace Support Forum Old Forums       CLOSED - General SQL Server       CLOSED - SQL Server 2005/Yukon  -------------------- Home Active Topics Frequently Asked Questions Member Information Search Page
 SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC