A number is stored and seen by a computer in binary format. So for example 4
is stored as
100 . When you want to see the number in decimal format you use printf("%d",
4);
Now there are more number systems than decimal format. Decimal format has
its number base 0-9.
Binary format has its number base 0-1. Hexadecimal format (your Hex) has its
number base consisted of 16 numbers (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). So
our 4 (in decimal format) is 4 in Hex too.
10 is A in Hex.
As i said your computer stores all the numbers in binary format. So
assigning a variable x as:
x=11;
or x=0xb; (0x indicates hexadecimal format)
is the same for your computer. To see the hexadecimal value without the 0x
of an integer in C use
printf("%x", variable);
e.g. printf("%x", 11);
%X makes the values appear in capital letterrs.
Ioannis
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of Caroline
> Tully
> Sent: Friday, January 05, 2001 11:12 AM
> To: 'dev...@li...'
> Subject: [Dev-C++] Hexadecimal Numbers
> Importance: High
>
>
> Help!!
> I'm working my way through a ' Teach yourself C ' book and have reached a
> Chapter about Hex.
> I wondered if anyone knew where I could get further information on Hex, as
> my book doesnt go into very much detail and it's making my head hurt!!!
> Please email me at ' car...@no... ' with any links.
> Cheers!
> Caroline
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users
>
|