Hex
Mon Sep 15 2008, 01:15 am
What is the data type for Hexadecimal?
I would like to know how to do the addition of 2 hexadecimal...
0x50 + 0x60 = 0xB0
how do you write it in c???
How to increment a hexadecimal of 0x10 every time it loops for 10 times...
I would like to know how to do the addition of 2 hexadecimal...
0x50 + 0x60 = 0xB0
how do you write it in c???
How to increment a hexadecimal of 0x10 every time it loops for 10 times...
Mon Sep 15 2008, 01:35 am
hi nismo,
i don't think there is any data type for hexadecimal. :-) .
even though u declare and assign decimal values to variables in c, they are invariably translated into hexadecimal values by the compiler . say u have a variable declared as
short int a=127;
this variable when translated (compiled) occupies only one byte and is assigned the value 07fh.So why do u want to try and add hex values when all the calculations can be done in decimal (much easier to understand and implement)?
can u elaborate(justify) the requirement u proposed?
:-)
As for ur code:
in this case c = 176 decimal which is equivalent to 0b0h.
as for the loop, translate the increment value 0x10 to decimal i.e. 16. to loop it ten times:
i don't think there is any data type for hexadecimal. :-) .
even though u declare and assign decimal values to variables in c, they are invariably translated into hexadecimal values by the compiler . say u have a variable declared as
short int a=127;
this variable when translated (compiled) occupies only one byte and is assigned the value 07fh.So why do u want to try and add hex values when all the calculations can be done in decimal (much easier to understand and implement)?
can u elaborate(justify) the requirement u proposed?
:-)
As for ur code:
short int a=0x50,b=0x60,c; c = a+b;
in this case c = 176 decimal which is equivalent to 0b0h.
as for the loop, translate the increment value 0x10 to decimal i.e. 16. to loop it ten times:
short int i,j=0; for (i=0,i<10,i++) { j +=16; //this is equivalent to j = j+ 0x10; }
[ Edited Mon Sep 15 2008, 01:43 am ]
Mon Sep 15 2008, 01:55 am
Actually i want to retrieve the data stored in the SD card which is in FAT16. The data stored in the SD card has the address of hexadecimal. Then i wish to retrieve the data in every single address from 0-0x1FF. Finally i want to see whether the data stored in the address 0x36 is 46(46 is ASCII which is alphabet F). Can you please help me?
Mon Sep 15 2008, 09:36 am
^^ for ascii 'digits' (ie 0,1,2,3....9) you simply add 30 to get the hex value.
eg ascii 2 is hex 32.
But for other characters you would need to make a lookup table...
eg ascii 2 is hex 32.
But for other characters you would need to make a lookup table...
Powered by e107 Forum System