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.
33 lines
866 B
33 lines
866 B
#define _CRT_SECURE_NO_DEPRECATE
|
|
#include <iostream>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char const* argv[])
|
|
{
|
|
|
|
if (argc != 2)
|
|
{
|
|
printf("%s 十六进制的数值\n", argv[0]);
|
|
return -1;
|
|
}
|
|
|
|
uint64_t input_num = 0;
|
|
sscanf(argv[1], "0x%x", &input_num);
|
|
|
|
|
|
int8_t int8_t_value = (int8_t)input_num;
|
|
int16_t int16_t_value = (int16_t)input_num;
|
|
int32_t int32_t_value = (int32_t)input_num;
|
|
int64_t int64_t_value = (int64_t)input_num;
|
|
printf("input : 0x%x\n", input_num);
|
|
printf("========================================\n");
|
|
printf("= int8_t_value : %d\n", int8_t_value);
|
|
printf("= int16_t_value: %d\n", int16_t_value);
|
|
printf("=int32_t_value: %d\n", int32_t_value);
|
|
printf("= int64_t_value: %ld\n", int64_t_value);
|
|
printf("=\n");
|
|
|
|
return 0;
|
|
}
|