Solved

Currency data type in MySQL: Decimal or Double?

Posted on 2007-03-29
2
13,704 Views
Last Modified: 2012-08-13
Dear Experts,

I've been using MySQL for some time now, but I haven't really explored the more advanced features. Regarding field types for currency, when should I use a decimal and when should I use a double?

Thanks in advance!
0
Comment
Question by:jericotolentino
2 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 18821750
Hello jericotolentino,

DECIMAL is exact numeric data types storing up to 65.30 numbers. The maximum number of digits for DECIMAL is 65. The maximum number of supported decimals is 30.

DOUBLE is approximate numeric data types. A double floating-point number is accurate to approximately 15 decimal places.

HTH,

!i!
0
 
LVL 10

Accepted Solution

by:
lahousden earned 125 total points
ID: 18826616
Usually when you are dealing with currency you will want to use DECIMAL. If you use DOUBLE you risk running into situations akin to those where people are sent bills for $0.00 (i.e. the database has stored a cumulated artihmetic result of, e.g., $0.00003267 or something and the program isn't aware it should write the tiny fraction off).
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
understanding output of mysql version 2 66
MySQL Error Code 2 25
mysql update statement 3 31
How do I setup Wordpress to use Master / Slave MySQL database setup? 4 55
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question