16进制转换成10进制
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
866 B

  1. #define _CRT_SECURE_NO_DEPRECATE
  2. #include <iostream>
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. int main(int argc, char const* argv[])
  7. {
  8. if (argc != 2)
  9. {
  10. printf("%s 十六进制的数值\n", argv[0]);
  11. return -1;
  12. }
  13. uint64_t input_num = 0;
  14. sscanf(argv[1], "0x%x", &input_num);
  15. int8_t int8_t_value = (int8_t)input_num;
  16. int16_t int16_t_value = (int16_t)input_num;
  17. int32_t int32_t_value = (int32_t)input_num;
  18. int64_t int64_t_value = (int64_t)input_num;
  19. printf("input : 0x%x\n", input_num);
  20. printf("========================================\n");
  21. printf("= int8_t_value : %d\n", int8_t_value);
  22. printf("= int16_t_value: %d\n", int16_t_value);
  23. printf("=int32_t_value: %d\n", int32_t_value);
  24. printf("= int64_t_value: %ld\n", int64_t_value);
  25. printf("=\n");
  26. return 0;
  27. }