Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

harry*333

macrumors 6502a
Original poster
Jul 24, 2009
505
28
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?
 
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?

A screenshot or cut and paste of output would be very helpful
 
Here's a test showing it. It doesn't truncate integer but it does with doubles.
 

Attachments

  • Untitled.png
    Untitled.png
    83 KB · Views: 166
Here's a test showing it. It doesn't truncate integer but it does with doubles.

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;
 
Last edited:
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(8);

cout << temp << endl;

Thanks! Somehow that completely slipped my mind
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.