hii everyone..
i just wanted to know the datatype for hex..how do we declare a hex number like 0x00800000 in C program
thanx
cutelucks
Printable View
hii everyone..
i just wanted to know the datatype for hex..how do we declare a hex number like 0x00800000 in C program
thanx
cutelucks
unsigned int or unsigned long, I'd guess.
Hexadecimal is just a way to represent a number, as is decimal and binary.
0x0F == 15 == 00001111
It's all the same thing. Deep down, the computer treats all numbers as binary, but it doesn't really matter. Numbers are numbers.
If you want to declare a number in hex, just do it, using any data type that you want.
Code:char c = 0x0A; /* 0x0A = 10 = '\n' */
Code:int x = 0xF0000000; /* Will be taken as a negative number because the sign bit is one.
If you declare x as an unsigned variable,
then it will be taken as a positive number */