comparison 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
comparison
equal deleted inserted replaced
225:243ed87880a1 226:28441920fb35
1 /*
2 * In version 2 of ThemWi owned number database, NANP numbers are stored as 3
3 * uint16_t words: NPA, exchange and prefix, each uint16_t encoding a group of
4 * 3 or 4 digits of the full telephone number. This library module provides
5 * functions for turning groups of 3 or 4 digits into uint16_t words.
6 */
7
8 digits3_to_uint16(str)
9 char *str;
10 {
11 int acc;
12
13 acc = (str[0] - '0') * 100;
14 acc += (str[1] - '0') * 10;
15 acc += str[2] - '0';
16 return acc;
17 }
18
19 digits4_to_uint16(str)
20 char *str;
21 {
22 int acc;
23
24 acc = (str[0] - '0') * 1000;
25 acc += (str[1] - '0') * 100;
26 acc += (str[2] - '0') * 10;
27 acc += str[3] - '0';
28 return acc;
29 }