Thread: strange output

  1. #1
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357

    strange output

    Why does this simple code display numbers in scientific notation?

    Code:
    #include < iostream >
    using namespace std;
    
    const double         r = 99.95;
    
    const unsigned short d = 2;
    
    int main( )
    {
    	unsigned short p;
    	
    	float  b;
    	float c;
    
    
    
    	cin >> p;
    
    	b =  p * r;
    
    	c = b;
    
    	cout.precision( 2 );
    	cout.setf ( ios::fixed || ios::showpoint );
    
    	cout << c     << endl;
    	cout << c / d << endl;
    
    	return 0;
    }
    when I remove precision and setf it works fine, but I want the formatting.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148
    Code:
    cout.setf ( ios::fixed | ios::showpoint );
    One'|' to much.

  3. #3
    Un Artiste Extraordinaire volk's Avatar
    Join Date
    Dec 2002
    Posts
    357
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Output an array in a textbox
    By Diablo02 in forum C# Programming
    Replies: 5
    Last Post: 10-18-2007, 03:56 AM
  2. Binary Search - Strange Output
    By mike_g in forum C Programming
    Replies: 13
    Last Post: 06-16-2007, 02:55 PM
  3. Connecting input iterator to output iterator
    By QuestionC in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2007, 02:18 AM
  4. Trying to store system(command) Output
    By punxworm in forum C++ Programming
    Replies: 5
    Last Post: 04-20-2005, 06:46 PM
  5. Really strange, unexpected values from allocated variables
    By Jaken Veina in forum Windows Programming
    Replies: 6
    Last Post: 04-16-2005, 05:40 PM