fork download
  1. #include <stdio.h>
  2.  
  3.  
  4. #define bytes_to_s16(MSB, LSB) (((signed int)((signed char)MSB))) << 8 | (((unsigned char)LSB))
  5. #define bytes_to_u16(MSB, LSB) (((unsigned int)((unsigned char)MSB))) << 8 | (((unsigned char)LSB))
  6.  
  7. int main(void) {
  8. // your code goes here
  9.  
  10.  
  11. printf("%d\n", bytes_to_s16(0x00,0x8e));
  12. printf("%d\n", bytes_to_u16(0x00,0x8e));
  13. printf("%d\n", bytes_to_s16(0xff,0x8e));
  14. printf("%d\n", bytes_to_u16(0xff,0x8e));
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
142
142
-114
65422