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 8049297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:45:10+00:00 2026-06-05T06:45:10+00:00

When i make the following multiplication in PHP: $ret = 1.0 * 0.000000001; i

  • 0

When i make the following multiplication in PHP:

$ret = 1.0 * 0.000000001;

i get the result: 1.0E-9

I want to convert this result into the normal decimal notation, how can i do this?

sprintf('%f',$ret) doesn’t work, it returns 0.000000. Overflow?

  • 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-05T06:45:12+00:00Added an answer on June 5, 2026 at 6:45 am

    sprintf('%f',$ret) doesn’t work, it returns 0.000000. Overflow?

    sprintf works, however you miss some point here.

    0.000000 is not overflow. It’s just that sprintf for the %f modifier uses 6 digits per default. Also please take care that %f is locale aware, %F is probably better suited.

    You might want to use more digits, e.g. let’s say 4 000 000 (four million):

    $ php -r "printf('%.4000000F', 1*0.000000001);"
    
    Notice: printf(): Requested precision of 4000000 digits was truncated to PHP maximum of 53 digits in Command line code on line 1
    
    Call Stack:
        0.0001     319080   1. {main}() Command line code:0
        0.0001     319200   2. printf() Command line code:1
    
    0.00000000100000000000000006228159145777985641889706869
    

    As this example shows, there is not only a common value (6 digits) but also a maximum (probably depended on the computer system PHP executes on), here truncated to 53 digits in my case as the warning shows.

    Because of your question I’d say you want to display:

    0.000000001
    

    Which are nine digits, so you need to write it that way:

    sprintf('%.9F',$ret)
    

    However, you might want to do this:

    rtrim(sprintf('%.20F', $ret), '0');
    

    which will remove zeroes from the right afterwards:

    0.000000001
    

    Hope this is helpful.

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

Sidebar

Related Questions

i have two strings in a php i want to make following checks in
If I make the following call in PHP it will use my password and
I can't make the following work. I know it's because of the PHP function
How do I make the following url forbidden in apache; main/index.php?site=ing I have tried
How to make the following table into a JSON string in jquery/javascript? <table> <thead>
I want to make the following use .attr(); selectbox.options[selectbox.selectedIndex].value sadly, selectbox.options[selectbox.selectedIndex].attr("value") is not the
I want to make following function: 1)input is a number. 2)functions are indexed, return
I want to make the following using list in HTML The following are the
How can I make the following code work? During compilation I get an error
I want to make following code work: Mylist lst; vector<int> v = lst; So

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.