- Details
- Category: PHP/MySQL Hacks and Tutorials
- Saturday, Mar 26th 2011 9:33pm
Store money into MySQL
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
MySQL permits a nonstandard syntax:
FLOAT(orM,D)REAL(orM,D)DOUBLE PRECISION(. Here, “M,D)(” means than values can be stored with up toM,D)Mdigits in total, of whichDdigits may be after the decimal point. For example, a column defined asFLOAT(7,4)will look like-999.9999when displayed. MySQL performs rounding when storing values, so if you insert999.00009into aFLOAT(7,4)column, the approximate result is999.0001.Because floating-point values are approximate and not stored as exact values, attempts to treat them as exact in comparisons may lead to problems. They are also subject to platform or implementation dependencies. For more information, see Section C.5.5.8, “Problems with Floating-Point Values”
For maximum portability, code requiring storage of approximate numeric data values should use
FLOATorDOUBLE PRECISIONwith no specification of precision or number of digits.




















