B_M's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
22 (0.02 per day)
Joined:
01-August 11
Profile Views:
259
Last Active:
User is offline Oct 10 2012 07:34 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   B_M has not set their status

Posts I've Made

  1. In Topic: Displaying double in scientific format and fixed format. No built-in.

    Posted 9 Oct 2012

    View Postjimblumberg, on 09 October 2012 - 10:40 PM, said:

    Without being able to use the manipulators trying to get your program to produce the desired output will be very difficult. You will probably need to convert the numbers to strings in order to manually format the numbers. And trying to figure out how to format a number in scientific notation is probably above your pay grade. I suggest you ask your instructor if using the iomanipulators is acceptable. I really think your instructor is trying to show you how to properly use the different namespace scoping methods but you need to ask.

    Jim



    Totally agree(way above my knowledge). Or I can also do the operator overloading (<<) and hard code the output so that when I call "cout<< something" then the output will display the x or y in scientific/fixed format.

    Thanks alot.
  2. In Topic: Displaying double in scientific format and fixed format. No built-in.

    Posted 9 Oct 2012

    View Postjimblumberg, on 09 October 2012 - 10:29 PM, said:

    Why? But it's possible to use the using std::scientific; clause but the proper way would be to use the scope resolution operator:: as shown.

    Jim



    I know what you mean by that. But that is the question's requirement. Anyhow, I think I am just going to do the std::scientific way...because I can't find any other way to convert double to scientific or fixed...
  3. In Topic: Displaying double in scientific format and fixed format. No built-in.

    Posted 9 Oct 2012

    Let me restate my problem.
    I am given the following.
    #include <iostream>
    using std::cout;
    using std::endl;
    
    int main()
    {
     double x = 0.001234567;
     double y = 1.946e9;
    }
    
    

    Question:
    Write the complete program using the above to get the following output.
    Displayed in default format:
    0.00123457  1.946e+009
    Displayed in scientific format:
    1.234567e-003 1.946000e+009
    Displayed in fixed format:
    0.001235  194000000.000000
    
    


    That is all about the question.
    And I think I am not allow to use or add in either std::scientific or std::fixed.
  4. In Topic: Displaying double in scientific format and fixed format. No built-in.

    Posted 9 Oct 2012

    View Postjimblumberg, on 09 October 2012 - 10:14 PM, said:

    If you are not using the using namespace std; clause you must properly scope your functions for example without any using statements your cout would look like:
    std::cout << std::scientific << a << '\t' << b << '\t' << c << std::endl;
    


    Jim



    Thanks Jim.
    But is there other way to do it without using "std::scientific" or "std::fixed"??
  5. In Topic: Displaying double in scientific format and fixed format. No built-in.

    Posted 9 Oct 2012

    if we use the following
    using namespace std;
    
    

    then we are able to do following
    cout << scientific << a << '\t' << b << '\t' << c << endl;
    
    


    if we are only given
    using std::cout;
    using std::endl;
    
    

    the "scientific" keyword is not functioning.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

B_M hasn't added any friends yet.

Comments

B_M has no profile comments yet. Why not say hello?