# convert 4 bits Hex to decimal

This is a discussion on convert 4 bits Hex to decimal within the C Programming forums, part of the General Programming Boards category; how to convert 4 bits in hexadecimal to decimal ? example : Code: 11A2A311 result : Code: 295874833 Thanks...

1. ## convert 4 bits Hex to decimal

how to convert 4 bits in hexadecimal to decimal ?
example :
Code:
`11A2A311`
result :
Code:
` 295874833`
Thanks

2. what do you mean "4bits in hexadecimal"?

0x11A2A311 in decimal is 295871249, not 295874833, so I don't really understand your question.

3. 0x11A2A311 in decimal is 295871249, not 295874833
yes,
what do you mean "4bits in hexadecimal"?
Code:
`HEX(11A2A311) equal 295871249 in DECIMAL`
Thanks

4. So, you still haven't clarified what you mean by "4 bits in hexadecimal"?

Do you just want to convert a hexadecimal string to decimal? I'm going to assume that. If so, the easiest way is to use sscanf with a %x format specifier into an int then printf the int with %d.

5. FYI, 0x11A2A311 won't fit in 4 bits. 0xF is the largest number you can fit into 4 bits. Maybe you meant 4 bytes?