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 = -2048;
  14. int32_t pos = 4;
  15. //int32_t pos_vel = pos | (((uint32_t)vel) & 0xFFF) << 20;
  16. int32_t pos_vel = pos | (vel & 0xFFF) << 20;
  17. printf("\n%d", pos_vel);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
-1
-2
-2147483644