I have to write an algorithm in java where I have to find ASCII value of 7 digit 1’s complement of a string(char) in java.
e.g. the first character of the string is ‘>’,
then decimal & hex ASCII value of the same is 62 & 0x3E respectively,
7 digit 1’s complement of that character will be 65 in decimal & 0x41 in Hex
which represents ‘A’,
thus ‘>’ will be interpreted as ‘A’
It is already written in C/C++(which I don't understand much :( ) as below
unsigned char br, i = 0;
unsigned char s[] = "E.515249,Q3:+18+900;073.929418,1";
unsigned char s1[] = "515Q.943:+1818,1900;249,+073.92";
unsigned long HMValue = 12345678;//2147483647;
//signed char LCDValue[] = " ";
for(br= 43 ; br<= 90; br++)
printf("%c, %c, %d \n", br, ((~br) & 0x7F), ((~br) & 0x7F));
printf("\n%s \n", s);
while (s[i] != NULL)
{
s1[i] = ((~s[i]) & 0x7F);
printf("%c", s1[i]);
i++;
}
I don't understand what is done in above code, but have to write simillar code in java.
Finally I'm going to use that logic in Android application. I hope it doesn't make any difference from java to Android.
I expect at least code in Java to find 7 digit 1's compliment of a character
Thanks in advance.
0 comments:
Post a Comment