Hello All

I am trying to format my program's output to be nicer than what it is doing now, and am looking for something equivalent to the noshowpoint that would act on the fixed manipulator. Here is the story:

I have a sequential integer number that is acting as a counter on the left.

I have a random number declared as double[this is the number that I get the square root of] next.

I have the square root of number next, also declared as double.

Then comes the number squared, also declared as double, and next,

The number cubed, also declared as double, last.

I want to store the:
Sequential number and number itself looking like integers, with no trailing zeros.

Square root of number as fixed with setprecision(2)

number squared and the number cubed as fixed but with no trailing zeros looking like integers.

I think I need to stop the fixed manipulator's effect after the storage of the square root of the number, how do I do that, or is it something else that I need to reset?

Here is the code, and sorry if it is not as pretty as others, if you know how to make it pretty let me know.


//Send the results to Data file.
outputFile << noshowpoint; //Change Formatting.
outputFile << setw(3) << iCounter << "\t";
outputFile << setw(7) << dNumber << "\t\t";
outputFile << showpoint << setprecision(2) << fixed; //Change Formatting.
outputFile << setw(10) << dSquareRoot << "\t";
outputFile << noshowpoint << fixed; //Change Formatting.
outputFile << setw(15) << dSquared << "\t";
outputFile << setw(20) << dCubed << endl;

//Increment iCounter and continue.
} //End of While Loop.

std::cout << 1.0/3 << '\t'
            << std::fixed << std::setprecision(2) 
            << 1.0/3 << '\t'
            << std::resetiosflags(std::ios::fixed)
            << std::setprecision(-1) << 1.0/3 << '\n' ;
This article has been dead for over six months. Start a new discussion instead.