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

  • SEARCH
  • Home
  • 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 1089555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:14:24+00:00 2026-05-16T23:14:24+00:00

I store money values in my db table. E.g. I have 2.50 . But

  • 0

I store money values in my db table. E.g. I have 2.50. But when I print that value the 0 is always missing so I get 2.5. The db table money field has the following type: decimal(6,2)

any idea how to fix that?

  • 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-05-16T23:14:25+00:00Added an answer on May 16, 2026 at 11:14 pm

    By default PHP echo and print don’t print the trailing zeros of a floating point number.

    To overcome this you need to use printf as:

    $money = 2.50;
    
    printf("%.2f",$money); // prints 2.50
    
    echo $money;           // prints 2.5
    print $money;          // prints 2.5
    

    The format specifier used in printf is "%.2f" what it means is always print atleast two digits after the decimal point and if there are not so many digits use 0.
    Note that it is atleast two digits not equal to two digits. So if I print 1.234 with that format it will not truncate it to 1.23 but will print 1.234 and if I print 1 it will result in 1.00

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

Sidebar

Related Questions

I have a stored procedure that returns values from a temp table. In my
I'm using a decimal column to store money values on a database, and today
I need to store app specific configuration in rails. But it has to be:
I need to store user entered changes to a particular table, but not show
I store some time values in sqlite in %H:%M string format (for example 15:43),
I need to store phone numbers in a table. Please suggest which datatype should
In our inventory database (SQL Server 2008 std edition) we have a table (called
I have a stored procedure in an old SQL 2000 database that takes a
I need a table to store the state of a financial transaction. The state
I want to be able to store a decimal value in one column, and

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.