Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- double roundN(double r, unsigned short n)
- {
- return std::trunc((r * pow(10, n) + 0.5)) / pow(10, n);
- }
- int main(void)
- {
- double test = roundN(3.141588765, 6);
- std::cout << test << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement