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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:23:40+00:00 2026-06-01T05:23:40+00:00

As everybody knows, you have limited precision when you use printf to output the

  • 0

As everybody knows, you have limited precision when you use printf to output the value of a float.
However, there is a trick to increase the accuracy in the output, as this example shows:

#include <stdio.h>

int main()
{
    float f = 1318926965;        /* 10 random digits */
    printf("%10.f\n", f);        /* prints only 8 correct digits */
    printf("%10d\n", *(int*)&f); /* prints all digits correctly */
    return 0;
}

and my question is, why don’t people use this trick more often?

  • 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-01T05:23:41+00:00Added an answer on June 1, 2026 at 5:23 am

    April fool?

    Your “random number” 1318926965 have the same underlying representation both in decimal and floating-point form.

    Try another value, like 10. It will print as:

            10
    1092616192
    

    So to answer your question:

    and my question is, why don't people use this trick more often?
    

    Because only one day of the year is April Fools Day… The rest of the days the trick doesn’t work…

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

Sidebar

Related Questions

It seems that everybody knows you're supposed to have a clear distinction between the
I would like to have some information about this topic. Everybody knows that it's
As everybody knows there's no built-in function to remove the duplicates from an array
everybody Recently I have use ADT to develop the android 2.2 program. The program
Having a weird problem here. Everybody knows that if you use web.config's customErrors section
Everybody knows there are two extensions for memcache on PHP: memcache memcached You can
Everybody knows that in Python assignments do not return a value, presumably to avoid
Everybody knows that you should close a connection immediately after you finish using it.
As everybody knows the en-US Keyboard-layout is the best one for programming. So I'd
Ok maybe everybody knows how to do this, but I've never try it beacause

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.