-
February 24th, 2012, 03:18 AM
#1
[RESOLVED] [Code proposal] Convert byte array in ASCII to int
Hello,
This converts ASCII data to the equivalent int as if we had converted the string into the meaning int.
Comments and feedback appreciated, thanks !
Code:
public int iByteArrayASCIIToInt(byte[] bTable, int iStart, int iEnd)
{
int retval;
int i;
int iNumberOfElements;
iNumberOfElements = iEnd - iStart;
retval = 0;
for (i = 0; i <= iNumberOfElements; i++)
{
retval += (bTable[iStart + i] - 0x30) * (int)Math.Pow(10, iNumberOfElements - i);
}
return retval;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|