Xcode Truncating Output

Discussion in 'Mac Programming' started by harry*333, Nov 2, 2014.

  1. harry*333 macrumors 6502a

    harry*333

    Joined:
    Jul 24, 2009
    #1
    I'm working in Xcode on a C++ project and for some reason the console output truncates everything to 6 significant figures. I've looked at the variables in the debugger and the data is there but just not being outputted. Anyone know why Xcode is doing this?
     
  2. robvas macrumors 68020

    Joined:
    Mar 29, 2009
    Location:
    USA
    #2
    A screenshot or cut and paste of output would be very helpful
     
  3. harry*333 thread starter macrumors 6502a

    harry*333

    Joined:
    Jul 24, 2009
    #3
    Here's a test showing it. It doesn't truncate integer but it does with doubles.
     

    Attached Files:

  4. subsonix, Nov 2, 2014
    Last edited: Nov 2, 2014

    subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #4
    It has nothing to do with Xcode, but C++, it's the same for printf and the %f floating point format specifier, the default precision is 6 characters. To change that try this:

    Code:
    double temp = 0.123456789;
    
    cout.precision(9);
    
    cout << temp << endl;
    
     
  5. harry*333 thread starter macrumors 6502a

    harry*333

    Joined:
    Jul 24, 2009
    #5
    Thanks! Somehow that completely slipped my mind
     

Share This Page