home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d183 / mklib.lha / Mklib / Edlib / toint.c < prev   
Text File  |  1989-02-26  |  525b  |  20 lines

  1. /* edlib  version 1.0 of 04/08/88 */
  2. /*
  3.     toint is also not included in Manx. converts an ascii character
  4.     into its corresponding hexadecimal value. Can be used for
  5.     binary and decimal digits since these are subsets of the
  6.     hexadecimal character set.
  7. */
  8. int toint(c)
  9. char c;
  10. {
  11.     if ( c >= '0' && c <= '9') {
  12.         return( c - '0' );
  13.     } else if ( c >= 'a' && c <= 'f' ) {
  14.         return( c - 'a' +10 );
  15.     } else if ( c >= 'A' && c <= 'F' ) {
  16.         return( c - 'A' +10 );
  17.     } else
  18.         return(-1);
  19. }
  20.