Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:47:11+00:00 2026-06-05T10:47:11+00:00

This question has been asked many times before, but I’ve found conflicting opinions on

  • 0

This question has been asked many times before, but I’ve found conflicting opinions on the topic so I thought I would bring it up again in hopes of a more unified conclusion.

I would like to store a currency value in my database. Let’s assume all entries are the same type of currency (USD for example) and that both positive and negative values are allowed.

My initial thought would be to store the value as a signed integer in terms of the smallest unit of the associated currency. For example, if I want to store the value $1.25, I would insert 125 into the database, since the smallest unit of USD is $0.01. The nice thing about this method is that MySQL will automatically round to the nearest integer. For example, if the dollar value is $1.259, I could insert 125.9, which would automatically be rounded and stored as 126 or $1.26.

So, what do you think? Is this a sound approach or is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:47:13+00:00Added an answer on June 5, 2026 at 10:47 am

    Financial data can be stored as DECIMAL(p,s) where p is the number of significant digits, and s is the scale (number of places to the right of the decimal point). See The MySQL documentation.

    Also from O’Reilly’s High Performance MySQL, chapter 3:

    “…you should use DECIMAL only when you need exact results for
    fractional numbers–for example, when storing financial data.”

    From O’Reilly’s Learning MySQL:

    DECIMAL is, “…A commonly used numeric type. Stores a fixed-point
    number such as a salary or distance…”

    And MySQL Pocket Reference:

    DECIMAL “…Stores floating-point numbers where precision is
    critical, such as for monetary values.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this question has been asked many times before, but I never found a
I know this question has been asked many times before, but I haven't found
I know this is a question that has been asked many times before, but
This question has been asked many times before but none of the previous ones
I know this question has been asked so many times before. But I just
This question has been asked many times before, but they all seem to relate
This question has been asked many times before but it seems everyone else is
I know this question has been asked many times before but I can't find
I know this question has been asked so many times before but I couldn't
I know this question has been asked many times before, but any of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.