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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:23:23+00:00 2026-05-16T05:23:23+00:00

I was making a program that rounds up numbers with various decimal places, so

  • 0

I was making a program that rounds up numbers with various decimal places, so as an example 2001.3666 would end up as 2001.37, I managed to make this work by adding 0.005 then times 100 and converted to a int and then divided again by 100.

Everything worked fine, no issues there, was having some fun making some loops too and stuff, but then everything became odd.

you see the first line of then program that repeats what the user typed in begun to display the rounded figure instead of the actual figure the user typed.

after a while I came to the conclusion that it wasn’t my code, because I started a new project and quickly made up this code:

#include <iostream>
#include <string> 
using namespace std;


int main()
{
  cout << "enter: ";
  double numberWithDecimalPlaces;
  cin >> numberWithDecimalPlaces;
  cout << "you entered " << numberWithDecimalPlaces << endl;

  system("pause");
  return 0; 
}

I type in 2001.3666 and the program goes to a newline even though I didn’t code that in and replies with 2001.37

its exact output is:

enter: 2001.3666
you entered 2001.37

now this is a brand new program in a new project without any of the same variable names as my earlier project and the user input figure is being rounded up, unless cin >> variable is automatically rounding up which i find unlikely it looks like some code from the earlier program is still in memory and conflicting with this code.

which is again unlikely right??

i’m using visual studio 2010 on win7

  • 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-16T05:23:24+00:00Added an answer on May 16, 2026 at 5:23 am

    The default precision for cout in C++ is 6 digits, and so 2001.3666 will display as 2001.37, but 201.3666 should display as 201.367.

    You can increase the precision like this:

    #include <iomanip>
    ...
    cout << "you entered " << setprecision(10) << numberWithDecimalPlaces << endl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a program that fits the wizard concept ideally; the user is walked
I'm making a program that retrieves decently large amounts of data through a python
I'm experimenting with internationalization by making a Hello World program that uses properties files
I'm fairly new to C# programming. I am making a program for fun that
I'm making a C program where I need to get the directory that the
I am making an application that does some custom image processing. The program will
How would a go about making a program where the user enters a string,
I'm making a program that can access data stored inside a class. So for
I am making a program that will run a persons C++ code from PHP.
hey, am making a program that makes the forms and controls dynamically from xml

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.