SBAA588 April 2024 LM73 , LM75B , LM95071 , TMP100 , TMP101 , TMP102 , TMP103 , TMP104 , TMP107 , TMP1075 , TMP108 , TMP112 , TMP114 , TMP116 , TMP117 , TMP121 , TMP122 , TMP123 , TMP124 , TMP126 , TMP144 , TMP175 , TMP1826 , TMP1827 , TMP275 , TMP400 , TMP401 , TMP411 , TMP421 , TMP422 , TMP423 , TMP431 , TMP432 , TMP435 , TMP451 , TMP461 , TMP464 , TMP468 , TMP4718 , TMP75 , TMP75B , TMP75C
/* C Signed Types */
unsigned char x = 0xFF;
signed char y = 0xFF;
/* x is treated as 255 and y as -1 */
/* C99 fixed width integer types */
uint8_t x = 0xFF;
int8_t y = 0xFF;
/* x is treated as 255 and y as -1 */
Bits | Data Type | Fixed Width Type | Format String |
---|---|---|---|
8 | char | int8_t / uint8_t | %hhi |
16 | short int | int16_t / uint16_t | %hi |
32 | int | int32_t / uint32_t | %i |
/* C Parsing and Outputting Hex */
char *s = "0xFF";
uint8_t x;
sscanf(s, "%hhi", &x);
/* x is 255 */
/* printf without length modifier */
printf("%i, %d, %u, %x\n", x, x, x, x);
/* "-1, -1, 4294967295, ffffffff" is printed due to coercion into 32 bit types and sign-extend */
/* printf with length modifier */
printf("%hhu, 0x%hhX, %#hhX\n", x, x, x);
/* the desired "255, 0xFF, 0XFF" is printed */
A | B | |
---|---|---|
1 | F | =HEX2DEC(A1) |
2 | 10 | =DEC2HEX(A2) |
/* JavaScript Parsing and Outputting Hex */
let x = 0xA
let y = parseInt("0xA")
let z = (10).toString(16)
let s = "0x" + x.toString(16).toUpperCase().padStart(2,'0')
/* x and y are 10, z is 'a' and s is '0x0A' */
# Python Parsing and Outputting Hex
x = 0xA
y = int("A",base=16)
z = hex(10)
# x and y are 10, z is '0xa'