FreeCalypso > hg > themwi-system-sw
diff libutil/digit_groups.c @ 226:28441920fb35
beginning of number database version 2
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 13 Aug 2023 22:01:25 -0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libutil/digit_groups.c Sun Aug 13 22:01:25 2023 -0800 @@ -0,0 +1,29 @@ +/* + * In version 2 of ThemWi owned number database, NANP numbers are stored as 3 + * uint16_t words: NPA, exchange and prefix, each uint16_t encoding a group of + * 3 or 4 digits of the full telephone number. This library module provides + * functions for turning groups of 3 or 4 digits into uint16_t words. + */ + +digits3_to_uint16(str) + char *str; +{ + int acc; + + acc = (str[0] - '0') * 100; + acc += (str[1] - '0') * 10; + acc += str[2] - '0'; + return acc; +} + +digits4_to_uint16(str) + char *str; +{ + int acc; + + acc = (str[0] - '0') * 1000; + acc += (str[1] - '0') * 100; + acc += (str[2] - '0') * 10; + acc += str[3] - '0'; + return acc; +}