/***************************************************************************
 *                                                                         *
 *   HEXVAL.C                                                              *
 *                                                                         *
 *   Copyright (c) 1997      Galacticomm, Inc.      All Rights Reserved.   *
 *                                                                         *
 *   Hexadecimal digit manipulation functions.                             *
 *                                                                         *
 *                                            - J. Alvrus   5/29/97        *
 *                                                                         *
 ***************************************************************************/

#include "gcomm.h"

#define FILREV "$Revision: 2 $"

INT
hexval(                            /* get hexadecimal value from digit     */
CHAR dig)                          /*   hexadecimal digit to convert       */
{
     ASSERT(isxdigit(dig));
     if (isdigit((dig=toupper(dig)))) {
          return(dig-'0');
     }
     return((dig-'A')+10);
}

CHAR
hexdig(                            /* get hexadecimal value from digit     */
UINT val)                          /*   value to convert                   */
{
     CHAR digits[16]="0123456789ABCDEF";

     ASSERT(val < 16);
     return(digits[val]);
}
