Solved

Currency data type in MySQL: Decimal or Double?

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…
Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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