Newer
Older
Microsoft / tohex2 / TOHEX2.C
@tundra tundra on 24 May 2012 705 bytes Initial revision
/* TOHEX2.C - 	This function is passed an integer value and an array
				location which can hold at least a 2 element string.
				The low 8 bits of the integer are converted to an
				equivalent hexadecimal string which is stored in the
				array at subscripts 0 and 1.

	Last modified: 08/31/86 - Copyright (c) 1985, 1986 By T.A. Daneliuk		*/


tohex2(i,array)

int		i;
char	array[];

{

int		temp;
static char	conv[]={"0123456789ABCDEF"};

temp=i;
temp=temp & 0x000f;							/* Mask all but low nybble */
array[1]=conv[temp];						/* Use to index into conversion table */
temp=i;										/* Now do high nybble */
temp=temp >> 4;
temp=temp & 0x000f;
array[0]=conv[temp];

}