+ 7
You need to use setprecision() on the cout object. http://www.cplusplus.com/reference/iomanip/setprecision/ ex: std::setprecision(numberofdigits);
4th Sep 2017, 6:57 PM
Karl T.
Karl T. - avatar
4th Sep 2017, 6:58 PM
Manual
Manual - avatar
+ 6
Calculations in double are more precise but to output the result with a given number of digits you need to precise it....
4th Sep 2017, 7:02 PM
Karl T.
Karl T. - avatar
+ 6
Yes. You need to format the output.
4th Sep 2017, 7:15 PM
Karl T.
Karl T. - avatar
+ 5
Each Data type in C++ such a number types int, double , float, long double, have ranges.
4th Sep 2017, 6:59 PM
Manual
Manual - avatar
+ 5
double will not display extra zeros eg 14.0 - float would display the zero though
4th Sep 2017, 7:02 PM
Manual
Manual - avatar
+ 5
if you want a variable to have a certain amount of digits used the right data type for the job
4th Sep 2017, 7:04 PM
Manual
Manual - avatar
+ 5
@Christos if you give the value long (long doub) 12.0001 that number will be displayed if you give 12.000 double will ignore the zeros and output 12
4th Sep 2017, 7:17 PM
Manual
Manual - avatar
4th Sep 2017, 7:29 PM
Manual
Manual - avatar
+ 3
My mistake that code takes the remainer of what is not covered in a data type. max ranger if no value for a range
4th Sep 2017, 7:32 PM
Manual
Manual - avatar