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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:04:01+00:00 2026-06-05T20:04:01+00:00

I have the string temp[256] and inside it there’s a double number, such as

  • 0

I have the string temp[256] and inside it there’s a double number, such as 0.125 and such, and everything is going well though some times it gets a number that’s too big for a double number, like 0.888888888888888888888888888888888888888883, and the double number only holds like 7 numbers instead of all.

I’ve been using the atof to convert the string into the double, but I think the problem is the double here, because it doesn’t have enough space for all the numbers….
This is what I wrote :

char temp[256]; // Has the number inside it
double temp_num = 0; // need to put the string inside this variable
temp_num = atof(temp);
printf ("%f\n", temp_num);

the output from the print is fine as long as the number isn’t larger then 7 digits after the zero, but if it’s a number like 0.8815818188888888888888888888888888888888888888888143, it only prints me the 7 first digits, like in this example it’ll print 8815818 instead of the whole number…
so I guess I need a bigger variable ?

  • 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-05T20:04:02+00:00Added an answer on June 5, 2026 at 8:04 pm

    Printf have a default behavior of printing only 7 digits after the zero when dealing with doubles or floats however you can change that behavior and control how many numbers after the zero printf prints like this

    printf ("%.20f\n", temp_num);
    

    Here you get 20 digits after the zero.

    For more details please refer to:

    1. http://www.cplusplus.com/reference/clibrary/cstdio/printf/
    2. The c programming language second edition.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this: string uriString = @C:\Temp\test.html; Uri uri = new Uri(uriString);
Say we have the following string string data= /temp string; If we want to
I have this code: String temp = txtForm.Rtf; foreach (ReplaceStrut rs in replaceArray) {
I have this string: 0000000020C90037:TEMP:data I need this string: TEMP:data. With PHP I would
Ok, I have a string of the form string temp = http://www.example.com?file=666111&submitter=Betty&origin=Office&telNo=05555; what I
I have the following String[] temp; which returns red blue green I would like
I have a string eg. string a = OU=QALevel1,DC=CopTest,DC=copiun2,DC=com; now i want my temp
Suppose i have a string const char *temp = i am new to C
Suppose, I have the following string: string temp = "some string contains text which
I have a variable temp : String temp = Ms Abc`<abc@gmail.com`>;Mr Cde`<cde@mail.com`>;Miss Xyz`<xyz@mail.com`>; Now

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.