Solved

Currency data type in MySQL: Decimal or Double?

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Creating and Managing Databases with phpMyAdmin in cPanel.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

772 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

16 Experts available now in Live!

Get 1:1 Help Now