Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 0xFE mean in a C program?

Tags:

c

In the given program below,

void main()
{

       int x=0xFE;

       int y=0xF3;
      .....
}

What values are assigned by x=0xFE and y=0xF3? What does 0x represent?

like image 633
Nitin Avatar asked Aug 07 '11 17:08

Nitin


People also ask

What is 0x10 in C?

Prefixes which indicates the base. For example, 0x10 indicates the value 16 in hexadecimal having prefix 0x.

What does 0x00 mean in hex?

An all-zero octet.


1 Answers

Writing a value with 0x before means it is written in hexadecimal notation, where the numbers 0-9 and additional "number" A-F are used to get a number system with the base 16. The big advantage of this is that each hexadecimal digit represents exactly 4 bits.

0xFE = 254
0xF3 = 243

So x = 254 and y = 243.

like image 126
Anders Abel Avatar answered Oct 19 '22 14:10

Anders Abel