fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. int main(void) {
  4. // your code goes here
  5. int32_t offset_initial = -1760;
  6. int32_t r = (offset_initial * 2) / 1000;
  7.  
  8. int32_t offset = (r + 1) >> 1;
  9. printf("%d", offset);
  10. int32_t position = -5;
  11. int32_t position_shifted = position / 2;
  12. printf("\n%d", position_shifted);
  13. int32_t vel = 2;
  14. int32_t pos = -4;
  15. //int32_t pos_vel = (pos & 0xFFFFF) | (((uint32_t)vel) & 0xFFF) << 20;
  16. int32_t pos_vel = (pos & 0xFFFFF) | (vel & 0xFFF) << 20;
  17. printf("\n%d", pos_vel);
  18. int32_t accum_el = -2000000000;
  19. // uint32_t accum_uint = accum_el;
  20. // int32_t adjust_el = accum_uint >> 24;
  21. // adjust_el &= (1 << 24) - 1;
  22. // accum_el = adjust_el;
  23. int32_t adjust_el = accum_el / (1 << 24);
  24. adjust_el &= (1 << 24) - 1;
  25. accum_el = adjust_el;
  26. printf("\n%d", accum_el);
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
-1
-2
3145724
16777097