Number data type

The Number data type enables you to enter numeric data; that is, numbers that will be used in mathematical calculations. (If you have data that will be used in monetary calculations, you should use the Currency data type, which performs calculations without rounding errors.)

The exact type of numeric data stored in a number field is determined by the Field Size property. Table 34-3 lists the various numeric data types, their maximum and minimum ranges, the decimal points supported by each numeric data type, and the storage (bytes) required by each numeric data type.

TABLE 34-3
Numeric Field Settings

Byte 0 to 255 None 1 byte
Integer –32,768 to 32,767 None 2 bytes
Long Integer –2,147,483,648 to 2,147,483,647 None 4 bytes
Double –1.797 × 10308 to 1.797 × 10308 15 8 bytes
Single –3.4 × 1038 to 3.4 × 1038 7 4 bytes
Replication ID N/A N/A 16 bytes
Decimal 1–28 precision 15 8 bytes

Many errors are caused by choosing the wrong numeric type for number fields. For instance, notice that the maximum value for the Integer data type is 32,767. We once saw a database that ran perfectly for several years and then started crashing with overflow errors. It turned out that the overflow was caused by a particular field being set to the Integer data type, and when the company occasionally processed very large orders, the 32,767 maximum was exceeded.

It is best to design your tables very conservatively and allow for larger values than you ever expect to see in your database. This is not to say that it is a good idea to use the Double data type for all numeric fields. The Double data type is very large (8 bytes) and is quite slow when used in calculations for another numeric operation. Instead, the Single data type is probably best for most floating-point calculations, and the Long Integer is best for most data where decimal points are irrelevant.

Add to Technorati Favorites


// Related Posted - GOOGLE!

Loading



Related Websites
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>