Thread: Storing prices View Single Post
 11-06-2012, 08:28 PM PM User | #6 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,949 Thanks: 75 Thanked 4,307 Times in 4,274 Posts Short answer: Yes. Longer answer re Decimal: MySQL stores decimal values in groups of 9 digits, either left of right of the decimal point. So although MySQL *enforces* DECIMAL(5,2) to only allow 3 digits left and 2 right of the decimal point, there's really no point in specifying such a small size. It will occupy the same amount of disk space as DECIMAL(18,9). Now, you may very well NOT want to allow more than 2 digits right of the decimal point, so a reasonable compromise is DECIMAL(11,2) -- 9 digits left, 2 digits right. That will occupy the same amount of disk space as DECIMAL(5,2) but give you flexibility in case someday you actually have a price of 1372.99 (for example). In short: There is little point in specifying a DECIMAL size smaller than DECIMAL(11,2) or DECIMAL(18,9) or any other combination that puts 9 digits left of the decimal point. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.
 Users who have thanked Old Pedant for this post: LearningCoder (11-06-2012)