Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/20/01 17:44
Read: times


 
#16740 - RE: ASCII to decimal or hexadecimal routine
If you send the data in a ascii hex format "0123456789ABCDEF", below is some 'c' code that can receive it.
<>< Lance.

<code>
byte getNibble( char hex_digit ) {
  char ch = getch();
  if ( ch >= '0' && ch <= '9' )
    return ch - '0';
  else
    return ch - 'A' + 10;
}// getNibble()

byte getByte() {
  return (getNibble()<<4) | getNibble();
}

short int getWord() {
  return (getByte()<<8) | getByte();
}

long int getLong() {
  return (getWord()<<16) | getWord();
}
</code>


List of 6 messages in thread
TopicAuthorDate
ASCII to decimal or hexadecimal routine            01/01/70 00:00      
RE: ASCII to decimal or hexadecimal routine            01/01/70 00:00      
RE: ASCII to decimal or hexadecimal routine            01/01/70 00:00      
RE: ASCII to decimal or hexadecimal routine            01/01/70 00:00      
RE: ASCII to decimal or hexadecimal routine            01/01/70 00:00      
RE: ASCII to decimal or hexadecimal routine            01/01/70 00:00      

Back to Subject List