previous | start | next

C hex constants

C interprets constant integers in the code as decimal notation and type int by default.

Constants can be written in hex notation in C by prefixing the constant with 0x:

unsigned int n;

n = 0x0000001D;   // 4 byte integer (8 hex digits); decimal value = 29



previous | start | next