Thread: 2.0e1.0 to 20.0

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    2

    Question 2.0e1.0 to 20.0

    need help converting an outputed double from 2.0e1.0 to 20.0!!!
    on a mac it would simply be cout << ... << fixed << showpoint << setprecision(1) << 20;
    but when i do that in VC++ it tells me fixed and showpoint are unidentified identifiers

    plz help!!!

    thanks!!

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2
    here's a sample of code that doesnt work:

    #include <iostream.h>
    #include <iomanip.h>

    int main() {
    cout << fixed << showpoint << setprecision(2) << 200;
    return 0;
    }

    VC++ will give me a compiling error of:
    fixed unidentified identifier
    showpoint unidentified identifier

    but then if i do:

    cout << setprecision(2) << 200;

    it will output:

    2.0e+2

    how can i make it so it outputs:

    200.00

    ?

    thanks in advance!!

  3. #3
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Code:
    using System;
    
    class DoubleOut
    {
    	public static void Main()
    	{
    		double x = 2.0e2;
    
    		Console.WriteLine("Number equals "+x);
    	}
    }
    One version with C#

  4. #4
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Maybe go with C on this:
    double num = 2e2;

    printf("Number is %.2lf", num);

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    use the new headers instead of the old so...

    #include<iostream>
    #include<iomanip>
    using namespace std;
    .
    .
    .
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed