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 2005 Forums
 Transact-SQL (2005)
 Float datatypes explained

Author  Topic 

Bex
Aged Yak Warrior

580 Posts

Posted - 2009-10-08 : 05:39:22
Can someone please expain how float datatypes are stored. I understand that they are 'inaccurate', but why, how?

The reason being is that I know float is not always accurate, and have to put forth a reason for not using them..... but I don't really know why they are inaccurate, or for what range of numbers.....

For instance, if we stored whole numbers that are simply converted to float (with no values in the decimal places), then is this ok to use float? Or if we wanted to store small numbers with 4 decimal places, then is this a bad choice?

Please can someone clarify, as what I've read so far has not satisfied my understanding!

Thanks

Hearty head pats

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-10-08 : 06:44:07
Well...according to Books Online float is "Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly". Check wikipedia for the details: http://en.wikipedia.org/wiki/Floating_point or just check MVJ's post here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=133548

- Lumbago
http://xkcd.com/327/
Go to Top of Page

Bex
Aged Yak Warrior

580 Posts

Posted - 2009-10-08 : 06:55:37
Thanks Lumbago.

That is EXACTLY what I wanted and has consolidated my understanding. Cheers

Hearty head pats
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-10-08 : 07:02:54
I found this article pretty interesting as well: http://blogs.msdn.com/khen1234/archive/2005/05/13/417153.aspx

- Lumbago
http://xkcd.com/327/
Go to Top of Page
   

- Advertisement -