|
|
|
|
| |
Table 2.8. How D Affects the Range of DECIMAL(M,D)
| Type Specification |
Range (for MySQL < 3.23) |
Range (for MySQL 3.23) |
| DECIMAL(4,0) |
–999 to 9999 |
–9999 to 99999 |
| DECIMAL(4,1) |
–9.9 to 99.9 |
–999.9 to 9999.9 |
| DECIMAL(4,2) |
–.99 to 9.99 |
–99.99 to 999.99 |
The range for a given DECIMAL type depends on your version of MySQL. As of MySQL 3.23, DECIMAL values are handled according to the ANSI specification, which states that a type of DECIMAL(M,D) must be able to represent any value with M digits and D decimal places. For example, DECIMAL(4,2) must be able to represent values from –99.99 to 99.99. Because the sign character and decimal point must still be stored, this requires an extra two bytes, so DECIMAL(M,D) values for MySQL 3.23 and later use M+2 bytes. For DECIMAL(4,2), six bytes are needed for the "widest" value (–99.99). At the positive end of the range, the sign byte is not needed to hold a sign character, so MySQL uses it to extend the range beyond that required by the ANSI specification. In other words, for DECIMAL(4,2), the maximum value that can be stored in the six bytes available is 999.99.
|
|
|
|
|
|
| Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist |
|