Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. double a = 6.352356663353535;
  2. double b = a.precision(5);
  3.  
  4. double a = 6.352356663353535;
  5. std::cout.precision(5);
  6. std::cout << a << std::endl;
  7.  
  8. #include <cmath>
  9. #include <cstdio>
  10. using namespace std;
  11. int main()
  12. {
  13. double a = 6.352356663353535;
  14. double intpart;
  15. double fractpart = modf (a, &intpart);
  16. fractpart = roundf(fractpart * 100000.0)/100000.0; // Round to 5 decimal places
  17. double b = intpart + fractpart;
  18. printf("%.5lf", b);
  19. }
  20.  
  21. 6.35236
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement