Advertisement
wagner-cipriano

C++ Float Precision: function setprecision C++

Jun 29th, 2020
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. //REF https://en.cppreference.com/w/cpp/io/manip/setprecision
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <limits>
  6. int main() {
  7.     const long double pi = std::acos(-1.L);
  8.     std::cout << "default precision (6):       " << pi << '\n'
  9.               << "Novamente, sem set precision " << pi << '\n'
  10.               << "max precision:               "
  11.               << std::setprecision(std::numeric_limits<long double>::digits10 + 1)
  12.               << pi << '\n';
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement