Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void print(double x)
- {
- if (x < 0)
- {
- cout << '-';
- x = -x;
- }
- cout << int(x);
- cout << '.';
- x -= int(x);
- x += 1e-7;
- double eps = 1e-6;
- for (int i = 0; i < 6; i++)
- {
- eps *= 10;
- x *= 10;
- cout << int(x) % 10;
- x -= int(x);
- if (x < eps)
- break;
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment