Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Currency data type in MySQL: Decimal or Double?

Posted on 2007-03-29
2
Medium Priority
?
13,716 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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