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.
| Author |
Topic |
|
MBeal
Posting Yak Master
110 Posts |
Posted - 2009-09-28 : 11:14:43
|
| I am confused about something. I am trying to understand percision Can someone explain this to me in english:"Is a floating point number data from - 1.79E + 308 through 1.79E + 308. n is the number of bits used to store the mantissa of the float number in scientific notation and thus dictates the precision and storage size. n must be a value from 1 through 53." (Found in BOL for Float)My second question is, if I am working with numbers (example: 10.05) and I am not concerned about values beyond the ".05", what data type should I use for this field? When I report on this data that is a float currently, I have a value in one of the fields of .00000000000028138888 I want to exclude anything past the second zero in this example. What data type should I use? Or does it have more to do with the storage?MBeal |
|
|
MBeal
Posting Yak Master
110 Posts |
Posted - 2009-09-28 : 11:40:26
|
| I've changed them to Decimal and set the percision to 18 and the scale to 2. It seems to have resolved my issue.MBeal |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-28 : 11:51:28
|
| sounds like a good solution. The simple explanation of the value of a FLOAT datatype is that it allows for a huge range of possible values. ie: both very large numbers and very small numbers can be stored in the same column. That is accomplished by providing the ability to "slide" the decimal point around rather than keeping a fixed scale and precision as with decimal/numeric datatypes. But what you gain by this large range can be a loss in precision. In my experience most business related situations don't require using a float datetype and I prefer not to use them.Be One with the OptimizerTG |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-09-28 : 12:08:33
|
The main drawback of float for business applications is that the numbers are binary, not decimal. There are numbers in decimal that have no exact representation in binary and numbers in binary that have no exact representation in decimal.This does mean that float is less precise. It just means that the float datatype does not conform well to standard decimal representations of numbers used in most business applications.For example:select X = 1.9EResults:X---------------------1.8999999999999999(1 row(s) affected) CODO ERGO SUM |
 |
|
|
|
|
|