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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/18/99 06:10
Read: times


 
#865 - RE: Converting and displaying a signed 8 bit numbe
You don't need table look up . You can use the code below hope it is working for you . I just wrote it and have no time to check for bug yet ..

Good Luck
Kris


void ByteToNum(char dip_read,char *str )
{
char index = 0 ;
//Check for minus sign bit
if ( dip_read & 0x80 )
{
//Copy minus sign to first chracter
str[index++] = '-' ;
//Clear minus bit
dip_read &= ~0x80 ;
}
str[index++] = '0' + (dip_read/100) ;
dip_read %= 100 ;
str[index++] = '0'+(dip_read / 10);
str[index++] = '0'+(dip_read % 10) ;
str[index] = '' ;
}
void ByteToHex(char dip_read,char *str )
{
char temp ;
temp = dip_read & 0x0F ;
if(temp < 10 )
str[1] = '0' + temp ;
else
str[1] = 'A' + (temp - 10 ) ;

temp = (dip_read & 0xF0) >> 4 ;
if(temp < 10 )
str[0] = '0' + temp ;
else
str[0] = 'A' + (temp - 10 ) ;
str[2] = '' ;
}



List of 4 messages in thread
TopicAuthorDate
Converting and displaying a signed 8 bit number.            01/01/70 00:00      
RE: Converting and displaying a signed 8 bit numbe            01/01/70 00:00      
RE: Converting and displaying a signed 8 bit numbe            01/01/70 00:00      
RE: Converting and displaying a signed 8 bit numbe            01/01/70 00:00      

Back to Subject List