Check out example codes for "set precision in c++". It will help you in understanding the concepts better.

Code Example 1

// setprecision example
#include <iostream>     // std::cout, std::fixed
#include <iomanip>      // std::setprecision

int main () {
  double f =3.14159;
  std::cout << std::setprecision(5) << f << '\n';
  std::cout << std::setprecision(9) << f << '\n';
  std::cout << std::fixed;
  std::cout << std::setprecision(5) << f << '\n';
  std::cout << std::setprecision(9) << f << '\n';
  return 0;
}

Code Example 2

float x;
cout<<fixed<<showpoint;
cout<<setprecision(2) << x;

Code Example 3

printf("%0.4f", num);

Code Example 4

int x = 109887;
cout << fixed << setprecision(3) << x;

Learn ReactJs, React Native from akashmittal.com