Thanks grumpy and sorry about the conversion error for 6844.
My long int is always under 65x10^6 (e.g. less than 80000000) so I assume I don't need to worry about signs.
I settled on a method that does not invoke dividing to shift out the bytes and it seems work. This is because although the long int bytes are stored in reversed order, the nibbles are in proper order.
The routine which I have been using and seems to work is shown below.
I think it is a bit verbose-I thought that perhaps C and its functions provided a "nice" way to simply convert long to hex in a buffer.
Thanks again-
Fritz
Code:
void cvt_long_to_hex(long int lngint, char hexout[4])
{
long int *liptr;
char *cptr;
liptr=&lngint;
cptr=(char*)liptr;
hexout[0]=cptr[3];
hexout[1]=cptr[2];
hexout[2]=cptr[1];
hexout[3]=cptr[0];
} //end cvt_long_to_hex