Saqib Shaikh writes:
> I'm interested to know what data type people consider suitable for storing > currency. As far as I know, the way to do it is to store the number of the smallest possible unit as an integer of some sort. You'll never run into any odd floating point-to-decimal conversion problems, but you might need to use BIGINT if you decide to to have many decimal places or if you're dealing with big numbers. If you use INT and store the price in cents, you'll run into problems around $20M. (I just use USD as an example.) To reduce rounding errors when converting back and forth, and to accomodate for a wide range of currencies, you might want to store more decimals for some currencies than for others. On the other hand, sums should always add up correctly, so this might be a stupid suggestion. //C -- Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/ Amiga user since '89, and damned proud of it too. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php