What is the point of using 0x1 in #define?

I came across a line of code that had something like below

#define IM 0x1

I know what IM is, but I am interested in knowing what it means 0x1and what its use and its value is for use in definition statements.

I am new to C and I was looking for this particular item but could not find it. Thanks in advance for your help.

+3
source share
4 answers

This is the hexadecimal number 1, usually determined this way when executing binary flags. So you will have

0x1
0x2
0x4
0x8
0x10

so that you can see the bits that you set.

+6
source

( 16). , , . - . ,

int x = 32;
x -= 8;

,

#define TOTAL_BITS 32
#define BITS_PER_BYTE 8

int x = TOTAL_BITS;
x -= BITS_PER_BYTE;

. (.. #define) , . , , .

+9

This is the number one expressed in hexadecimal form (base 16).

http://en.wikipedia.org/wiki/Hexadecimal

+4
source
#define IM    0x1

This is another positional number system: hexadecimal. Here it is the hexadecimal form of the number "1".

+3
source

All Articles