double and float ques

1
2
3
4
double v = 3.141592862343;
	cout<<"double = "<<v<<endl;
	float w = v;
	cout<<"float = "<<w<<endl<<endl;


output:

double = 3.14159
float = 3.14159

I was expecting that v would at least be printed in full b/c it has 8 byte storage. Why was it truncated?
Last edited on
looks like the default precision to me.
http://www.cplusplus.com/reference/iomanip/setprecision/
So when I type in a literal larger than the default I have to apply precision info to get the remaining information back (e.d. 3.4567-->setprecision(12)-->345673242345 (original number. Cutoff values are still stored.

Thx
It was a question...hope not a bad one!
Topic archived. No new replies allowed.