Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. double roundN(double r, unsigned short n)
  5. {
  6. return std::trunc((r * pow(10, n) + 0.5)) / pow(10, n);
  7. }
  8.  
  9. int main(void)
  10. {
  11. double test = roundN(3.141588765, 6);
  12. std::cout << test << '\n';
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement