Originally Posted by
EVOEx
Well... you could compare the result with 0x7FFFFF. If it's greater than that, then you can change the result by subtracting 0x1000000 from it.
Or, you could test the hob of the 24 bit number, and pad to the left with X'FF's if on.
As in
Code:
if (24_bit_value & 0x00800000) 24_bit_value |= 0xFF000000 ;
Or, since you are working with strings, you could test the first char too:
Code:
char newstring[9] = {0} ;
if ( string[0] == '8' || string[0]== '9' || (toupper(string[0] >= 'A' && toupper(string[0] <= 'F') ) {
strcat(newstring, "FF") ;
strcat(newstring, string) ;
}
else strcpy(newstring, string) ;
(not syntax checked)