+ 1

std::setprecision std::cout.precision

What is the difference is usage between std::cout.precision and std::setprecision? (except for setprecision <iomanip> is needed) It gives pretty same result I can't figure the difference

6th Oct 2022, 6:42 PM
Sashunia
Sashunia - avatar
3 Antworten
+ 4
There is no difference. std::setprecision(n) behaves the same as std::cout.precision(n). The only difference is that std::setprecision(n) is a stream manipulator, used like so std::cout << std::setprecision(3) << ...; (std::cout can be replaced by any derivative of std::ios_base) while std::cout.precision is a method
6th Oct 2022, 9:18 PM
XXX
XXX - avatar
0
🇺🇦 Vitya 🇺🇦 I believe you could help🙏
6th Oct 2022, 6:50 PM
Sashunia
Sashunia - avatar
0
XXX thanks a lot
7th Oct 2022, 1:34 PM
Sashunia
Sashunia - avatar