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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:35:01+00:00 2026-05-16T22:35:01+00:00

In C++, What are the random digits that are displayed after giving setprecision ()

  • 0

In C++,
What are the random digits that are displayed after giving setprecision() for a floating point number?

Note: After setting the fixed flag.

example:

float f1=3.14;
cout < < fixed<<setprecision(10)<<f1<<endl;

we get random numbers for the remaining 7 digits? But it is not the same case in double.

  • 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-16T22:35:02+00:00Added an answer on May 16, 2026 at 10:35 pm

    Two things to be aware of:

    1. floats are stored in binary.
    2. float has a maximum of 24 significant bits. This is equivalent to 7.22 significant digits.

    So, to your computer, there’s no such number as 3.14. The closest you can get using float is 3.1400001049041748046875.

    double has 53 significant bits (~15.95 significant digits), so you get a more accurate approximation, 3.140000000000000124344978758017532527446746826171875. The “noise” digits don’t show up with setprecision(10), but would with setprecision(17) or higher.

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

Sidebar

Related Questions

I want to generate a random number in PHP where the digits itself should
I want to generate a number that contains 14 digits. But I want to
Built an iPhone app that generates a random number to a label when a
my program generates random numbers with up to 6 digits with int number =
string str contains somewhere within it http://www.example.com/ followed by 2 digits and 7 random
I have strings of the form 000011122222 . That is, consecutive digits repeated random
I'm trying to generate 16 000 000 unique random numbers (10-digits: range 1 000
I want to know how to get a 4-digit random number in Java. I
I need to do a random with a 16-digit number. And the random function
A random class definition: class ABC: x = 6 Setting some values, first for

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.