avoid automatic round of

Apr 19, 2014 at 12:26pm
I have a double variable with large value if I print that, it show like this
10000000000000000, how to avoid the automatic round off please help me

int main () {
double f = 9999999999999999.9999;
cout <<f;
return 0;
}
Apr 19, 2014 at 12:50pm
I'm not sure how many digits you can store but you might try a long double.

You might also look into the difference between int and float and then look into unsigned long long int.
Last edited on Apr 19, 2014 at 12:52pm
Apr 19, 2014 at 1:07pm
i want to store( 20,4 )
Apr 19, 2014 at 1:24pm
double have about 15 decimal digits of precision
long double have about 18.

You will be better with storing whole and fractional parts in different variables.
Topic archived. No new replies allowed.