Discussion in "Software" started by    nismo    Sep 15, 2008.
Mon Sep 15 2008, 01:15 am
#1
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...
Mon Sep 15 2008, 01:35 am
#2
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:
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
#3
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, 02:33 am
#4
how to convert ascii to hex??
Mon Sep 15 2008, 09:36 am
#5
^^ 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...

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am