|
From: <cg...@wo...> - 2002-12-07 21:04:38
|
At the end I achieved to make it work. With my own function, setprecision(n) and setiosflags(ios::fixed). Then I tried with the code using the standard functions and the result was the same, as it would be expected. I don't understand the reason for this, that setprecision doesn't affect the precision, and is ios::fixed which really affect it (although perhaps it would need setprecision be set before). But I understand that if I set the precission to 6, e.g, I want to print all the significants numbers till the sixth decimal, and with exact precission, so if it sees the number 175.240236845 it will print the six decimals, having so 175.240237, but I don't want it to cut the number in its second decimal, giving 175.24, or adjusting from the third and leaving the rest being wrong, as seeing 54.2548245 and give 54.255387. That shall be the mission of setprecision, the ios::fixed is for displaying not significant 0s till reaching the total of decimals especified by the precision option, so with number 2.24504800000 being this: setprecision[p](9) ios::fixed[f] not defined: 2.245048 p(2) f not 2.25 p(9) f yes 2.245048000 p(2) f yes 2.251558745 |