FreeCalypso > hg > sms-coding-utils
view libcoding/hexdigits.c @ 28:6e925aa54727
libcoding: more sensible naming of GSM time
encoding and decoding modules
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Jun 2024 02:32:11 +0000 |
parents | cd2d82ec5144 |
children |
line wrap: on
line source
/* * This module contains elementary functions for working with hex digits. */ decode_hex_digit(c) { if (c >= '0' && c <= '9') return(c - '0'); if (c >= 'A' && c <= 'F') return(c - 'A' + 10); if (c >= 'a' && c <= 'f') return(c - 'a' + 10); return(-1); } encode_hex_digit(d) unsigned d; { if (d <= 9) return(d + '0'); else return(d - 10 + 'A'); }