setlocale(LC_ALL, "Portuguese");
double var = 1.0;
cout << var << endl;
system("pause");
return 0;
output:
1
Press any key to continue . . .
setlocale(LC_ALL, "Portuguese");
double var = 1.0;
cout << var << endl;
system("pause");
return 0;
output:
1
Press any key to continue . . .
float
and double
only represent the values of numbers. “1” and “1.0” are both numerals for the same number, so 1 is the correct value of the var
you set to 1.0. float
and double
do not represent the original numerals used to set their values, nor do they represent how much accuracy (relative to some ideal mathematical value) is present. The “1” you see as output is a result of default formatting. Other formatting options are available, but you must specify them yourself.