Solved

Currency data type in MySQL: Decimal or Double?

Posted on 2007-03-29
2
13,701 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now