0

when I...

double a = 0.00000001;
cout<< a <<endl;

The computer outputs 1e-07. I want to force the computer to write it as 0.00000001

thanks! ;)

3
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by MareoRaft
0

I also need to be able to right justify items I am printing, or add 0's to the beginning of integers so that they ALL are exactly 8 digits long. (my ints do not exceed 99999999)

0

setprecision must take away digits, but it will not add 0's when the integer is not long enough!

Thank you for your help so far. That was very useful and allowed me to fix part of my code :)

0

If you scroll to the bottom of that website you linked you will see unsetf().

Here is an example

#include <iostream>
using namespace std;

int main()
{
	cout.setf(ios_base::fixed);
	cout << 100.1 << endl; //with fixed
	cout.unsetf(ios_base::fixed);
	cout << 100.2 << endl; //without fixed

	return 0;
}

Edited by sfuo: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.