Database Reference
In-Depth Information
Table 3.2
Decimal and Numeric Storage Requirements
Precision
Storage
1 through 9
5 bytes
10 through 19
9 bytes
20 through 28
13 bytes
29 through 38
17 bytes
Money and Smallmoney
Both the money and the smallmoney data types store monetary values to
four decimal places. The only difference in these two types is that money
can store values from about -922 trillion through 922 trillion and requires
8 bytes of storage, whereas smallmoney holds only values of -214,748.3648
through 214,748.3647 and requires only 4 bytes of storage. Functionally,
these types are similar to decimal and numeric, but money and smallmoney
also store a currency symbol such as $ (dollar), ¥ (yen), or £ (pound).
Float and Real
Both float and real fall into the category of approximate numbers. Each
holds values in scientific notation, which inherently causes data loss be-
cause of a lack of precision. If you don't remember your high school chem-
istry class, we briefly explain scientific notation. You basically store a small
subset of the value, followed by a designation of how many decimal places
should precede or follow the value. So instead of storing 1,234,467,890 you
can store it as 1.23E+9. This says that the decimal in 1.23 should be moved
9 places to the right to determine the actual number. As you can see, you
lose a lot of detail when you store the number in this way. The original
number (1,234,467,890) becomes 1,230,000,000 when converted to scien-
tific notation and back.
Now back to the data types. Float and real store numbers in scientific
notation; the only difference is the range of values and storage require-
ments for each. See Table 3.1 for the range of values for these types. Real
requires 4 bytes of storage and has a fixed precision of 7. With float data,
you can specify the precision or the total number of digits, from 1 through
53. The storage requirement varies from 4 bytes (when the precision is less
than 25) to 8 bytes (when the precision is 25 through 53).
Search WWH ::




Custom Search