fork download
  1. #include <iostream>
  2. #include <cstdint>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int32_t in;
  8. cin >> in;
  9. const bool negative = in < 0;
  10. const uint32_t a = negative ? - in : in;
  11. const uint32_t half = a >> 1;
  12. const bool odd = a & 0x1;
  13. cout << (negative ? '-':' ') << half << '.' << (odd ? '5' : '0') << endl;
  14. return 0;
  15. }
Success #stdin #stdout 0s 5024KB
stdin
-24
stdout
-12.0