fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a = 1, b = 16; // ułamek 1/16
  6. int x = a;
  7.  
  8. cout << "0.";
  9.  
  10. while (x > 0) {
  11. x *= 2;
  12. if (x >= b) {
  13. cout << 1;
  14. x -= b;
  15. } else {
  16. cout << 0;
  17. }
  18. }
  19.  
  20. cout << endl;
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5308KB
stdin
1 16
stdout
0.0001