High Tech Sorcery

Archive for June, 2011

storing money in decimal fields in MySQL

by on Jun.15, 2011, under Uncategorized

I haven’t found a lot of advice about what precision values to use for storing money in decimal fields.  Here’s what I calculated.  The scale is going to be 2 for US currency which requires 1 byte of storage.

  • precision 4, scale 2 = 2 bytes of storage, 99.99 to -99.99
  • precision 6, scale 2 = 3 bytes of storage, 9999.99 to -9999.99
  • precision 8, scale 2 = 4 bytes of storage, 999999.99 to -999999.99 (I’ve tended to suggest this as a starting point)
  • precision 11, scale 2 = 5 bytes
  • precision 13, scale 2 = 6 bytes
  • precision 15, scale 2 = 7 bytes
  • precision 17, scale 2 = 8 bytes
Leave a Comment more...


Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...