Hex to Integer Pls Helpp!!
I don' t know anything about C/C++.
I have a data and a script. This script converts this data into X,Y coordinates and paints a graph...
I just need to know how this data converting...
I need to convert this data to create a graphic at php....
Can some one explain me this code?
My data is
80210021002100210022002300250025002600260026002700 28002B002C002E0030003100340036003A003F00420047004B 00500055005B00600068006F0078007F00880090009800A000 A900B100B900C100C900D000D700DE00E500EB00F000F700FC 01010105010A010F01140119011F012901390154018401DF02 7D0377
and my code is
int FrantionCount = 0;
POINT Fraktion  ;
POINT apt  ;
int KY = 0;
int j = 0;
int x = 150;
for (int i = 0; i < 1200 ; i = i + 4,j++)
CString Fraction = GragikLog.Mid(i,1);
int Y = BBHexToInt(GragikLog.Mid(i + 1,3));
//apt[j].y = currsatir + 1200 - Y / 3;
apt[j].y = currsatir + 1450 - Y / 3;
apt[j].x = x;
x = x + 7;
if (KY < apt[j].y)
KY = apt[j].y;
if (Fraction == '8' || Fraction == 'C')
Fraktion[FrantionCount].y = apt[j].y;
Fraktion[FrantionCount].x = apt[j].x;
CPen* pOldpen = PSS->dc->SelectObject(&pen);
for (i = 0; i < FrantionCount;i++)
PSS->dc->LineTo(Fraktion[i].x,KY + 30);
if (FrantionCount > 0)
PSS->dc->LineTo(Fraktion[FrantionCount - 1].x,KY);
PSS->dc->LPtoDP(apt, 300) ;
PSS->dc->Polyline (apt, 300);
//PSS->dc->LPtoDP(Fraktion, 10) ;
int BBHexToInt(CString& sHex)
int dgr = 0;
for(int i = sHex.GetLength() - 1,j =0; i >= 0;--i,++j)
double dgr0 = pow((double)16,(double)i);
if(sHex[j] >= '0' && sHex[j] <= '9')
dgr1 = sHex[j] - '0';
dgr1 = 10 + sHex[j] - 'A';
dgr += ((int)dgr0 * dgr1);
How big is the hex data (does 4 'digits' = 1 integer? there is no space, no end of line, to seperate it) Also, if you insist on doing it by hand, you must handle the endian issue as the byte pairs are flipped on windows compatible processors (intel, amd, etc).
There is a way to use %x to just convert directly from hex-text to numbers, much as you have the %d. Look at the scanf family or figure out how to do it with cstring.
Your complete lack of comments combined with useless variable names and confusing code keeps me from trying to unravel what you did in that segment. I don't mean to be harsh, but that half page of code would take me a couple of hours to figure out because of the style.
The data is 80210021002100210022002300250025002600260026002700 28002B002C002E0030003100340036003A003F00420047004B 00500055005B00600068006F0078007F00880090009800A000 A900B100B900C100C900D000D700DE00E500EB00F000F700FC 01010105010A010F01140119011F012901390154018401DF02 7D0377
I have no idea. I don' t the digit of them... I guess that It' s somewhere in the code...
When this data execute in this code can you simulate what will gonna happen?
Its going to print out meaningless output that you cannot tell anything about, because you don't know if its right or wrong. Can you make a single x/y pair in your original program and print that data here, something like (1000,16)?
Perhaps this simple, C style example will help somehow. But you STILL must know what the data file means or you will not get far.
using namespace std;
char ch = "ff 10";
int hex, hey;
sscanf(ch, "%x %x", &hex, &hey);
printf("%i %i \n",hex, hey);
I have solved my problem...
it' s coming as 4 digits like 8021 - 0021 ..... and goes on...
It seperates first digit... like 8 & 021 ... than It converts 021 to decimal... Because its Hex...
apt[j].y = currsatir + 1450 - Y / 3;
Y means hexdec("021")
So I have found the Y coordinate of the graphic... Then I applied same mental in my php code with ape chart component, I draw the graph...
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL