Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. HELP PLEASE!!! CRAZY COMPILERS?????

HELP PLEASE!!! CRAZY COMPILERS?????

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharphelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tguzella
    wrote on last edited by
    #1

    i need help: when i compile the following program (I have tested in bloodshed devc++, and visual c++ .net): --------------------------------------------------------------------------- #include #include #include #include using namespace std; int main() { float fnumber=1.123456789012345678; double dnumber=1.123456789012345678; long double ldnumber=1.123456789012345678; cout << "Float: " << fnumber << endl; cout << "Double: " << dnumber << endl; cout << "Long Double: " << ldnumber << endl; cout << "sizeof(float): " << sizeof(float) << endl; cout << "sizeof(double): " << sizeof(double) << endl; cout << "sizeof(long double): " << sizeof(long double) << endl; system("pause"); return 0; } ---------------------------------------------------------------------------- , the program outputs fnumber, dnumber and ldnumber (all of them) as 1.2346. i have no clue why this is happening... i am running this program on a athlon xp 2000+, under windows xp pro sp1... any help will be aprecciated...

    T M J 3 Replies Last reply
    0
    • T tguzella

      i need help: when i compile the following program (I have tested in bloodshed devc++, and visual c++ .net): --------------------------------------------------------------------------- #include #include #include #include using namespace std; int main() { float fnumber=1.123456789012345678; double dnumber=1.123456789012345678; long double ldnumber=1.123456789012345678; cout << "Float: " << fnumber << endl; cout << "Double: " << dnumber << endl; cout << "Long Double: " << ldnumber << endl; cout << "sizeof(float): " << sizeof(float) << endl; cout << "sizeof(double): " << sizeof(double) << endl; cout << "sizeof(long double): " << sizeof(long double) << endl; system("pause"); return 0; } ---------------------------------------------------------------------------- , the program outputs fnumber, dnumber and ldnumber (all of them) as 1.2346. i have no clue why this is happening... i am running this program on a athlon xp 2000+, under windows xp pro sp1... any help will be aprecciated...

      T Offline
      T Offline
      tguzella
      wrote on last edited by
      #2

      the preprocessors are iostream, float.h, windows.h (i forgot about html tags on the forum...)

      1 Reply Last reply
      0
      • T tguzella

        i need help: when i compile the following program (I have tested in bloodshed devc++, and visual c++ .net): --------------------------------------------------------------------------- #include #include #include #include using namespace std; int main() { float fnumber=1.123456789012345678; double dnumber=1.123456789012345678; long double ldnumber=1.123456789012345678; cout << "Float: " << fnumber << endl; cout << "Double: " << dnumber << endl; cout << "Long Double: " << ldnumber << endl; cout << "sizeof(float): " << sizeof(float) << endl; cout << "sizeof(double): " << sizeof(double) << endl; cout << "sizeof(long double): " << sizeof(long double) << endl; system("pause"); return 0; } ---------------------------------------------------------------------------- , the program outputs fnumber, dnumber and ldnumber (all of them) as 1.2346. i have no clue why this is happening... i am running this program on a athlon xp 2000+, under windows xp pro sp1... any help will be aprecciated...

        M Offline
        M Offline
        markkuk
        wrote on last edited by
        #3

        The default precision is the same for all floating-point types. Use the setprecision() manipulator or cout::precision() function to change the number of displayed digits.

        1 Reply Last reply
        0
        • T tguzella

          i need help: when i compile the following program (I have tested in bloodshed devc++, and visual c++ .net): --------------------------------------------------------------------------- #include #include #include #include using namespace std; int main() { float fnumber=1.123456789012345678; double dnumber=1.123456789012345678; long double ldnumber=1.123456789012345678; cout << "Float: " << fnumber << endl; cout << "Double: " << dnumber << endl; cout << "Long Double: " << ldnumber << endl; cout << "sizeof(float): " << sizeof(float) << endl; cout << "sizeof(double): " << sizeof(double) << endl; cout << "sizeof(long double): " << sizeof(long double) << endl; system("pause"); return 0; } ---------------------------------------------------------------------------- , the program outputs fnumber, dnumber and ldnumber (all of them) as 1.2346. i have no clue why this is happening... i am running this program on a athlon xp 2000+, under windows xp pro sp1... any help will be aprecciated...

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #4

          You need to tell cout that you want to see more digits than the default (six I think) is:

          [...]
          long double ldnumber=1.123456789012345678;

          cout.precision(20);
          cout << "Float: " << fnumber << endl;
          [...]


          Who is 'General Failure'? And why is he reading my harddisk?!?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups