1 /* Binary Coded Decimal <--> Densely Packed Decimal lookup tables.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Contributed by IBM Corporation. Author Mike Cowlishaw.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 /* ------------------------------------------------------------------------ */
23 /* For details, see: http://www2.hursley.ibm.com/decimal/DPDecimal.html */
25 /* This include file defines conversion tables for DPD, as follows. */
27 /* uint16_t BCD2DPD[2458]; // BCD -> DPD (0x999 => 2457) */
28 /* uint16_t DPD2BCD[1024]; // DPD -> BCD (0x3FF => 0x999) */
29 /* uint16_t BIN2DPD[1000]; // BIN -> DPD (999 => 2457) */
30 /* uint16_t DPD2BIN[1024]; // DPD -> BIN (0x3FF => 999) */
32 /* In all cases the result (10 bits or 12 bits, or binary) is right-aligned */
33 /* in the table entry. */
35 /* To use a table, its name, prefixed with DEC_, must be defined with a */
36 /* value of 1 before this header file is included. For example: */
37 /* #define DEC_BCD2DPD 1 */
38 /* ------------------------------------------------------------------------ */
42 const uint16_t BCD2DPD
[2458] = { 0, 1, 2, 3, 4, 5, 6, 7,
43 8, 9, 0, 0, 0, 0, 0, 0, 16, 17, 18, 19, 20,
44 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 32, 33,
45 34, 35, 36, 37, 38, 39, 40, 41, 0, 0, 0, 0, 0,
46 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 0,
47 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, 70, 71, 72,
48 73, 0, 0, 0, 0, 0, 0, 80, 81, 82, 83, 84, 85,
49 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 96, 97, 98,
50 99, 100, 101, 102, 103, 104, 105, 0, 0, 0, 0, 0, 0,
51 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 0, 0, 0,
52 0, 0, 0, 10, 11, 42, 43, 74, 75, 106, 107, 78, 79,
53 0, 0, 0, 0, 0, 0, 26, 27, 58, 59, 90, 91, 122,
54 123, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 42, 43, 74,
60 75, 106, 107, 78, 79, 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0,
63 0, 0, 0, 0, 144, 145, 146, 147, 148, 149, 150, 151, 152,
64 153, 0, 0, 0, 0, 0, 0, 160, 161, 162, 163, 164, 165,
65 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, 176, 177, 178,
66 179, 180, 181, 182, 183, 184, 185, 0, 0, 0, 0, 0, 0,
67 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 0, 0, 0,
68 0, 0, 0, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
69 0, 0, 0, 0, 0, 0, 224, 225, 226, 227, 228, 229, 230,
70 231, 232, 233, 0, 0, 0, 0, 0, 0, 240, 241, 242, 243,
71 244, 245, 246, 247, 248, 249, 0, 0, 0, 0, 0, 0, 138,
72 139, 170, 171, 202, 203, 234, 235, 206, 207, 0, 0, 0, 0,
73 0, 0, 154, 155, 186, 187, 218, 219, 250, 251, 222, 223, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
79 0, 0, 0, 0, 138, 139, 170, 171, 202, 203, 234, 235, 206,
80 207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 257, 258,
82 259, 260, 261, 262, 263, 264, 265, 0, 0, 0, 0, 0, 0,
83 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 0, 0, 0,
84 0, 0, 0, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
85 0, 0, 0, 0, 0, 0, 304, 305, 306, 307, 308, 309, 310,
86 311, 312, 313, 0, 0, 0, 0, 0, 0, 320, 321, 322, 323,
87 324, 325, 326, 327, 328, 329, 0, 0, 0, 0, 0, 0, 336,
88 337, 338, 339, 340, 341, 342, 343, 344, 345, 0, 0, 0, 0,
89 0, 0, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 0,
90 0, 0, 0, 0, 0, 368, 369, 370, 371, 372, 373, 374, 375,
91 376, 377, 0, 0, 0, 0, 0, 0, 266, 267, 298, 299, 330,
92 331, 362, 363, 334, 335, 0, 0, 0, 0, 0, 0, 282, 283,
93 314, 315, 346, 347, 378, 379, 350, 351, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99 266, 267, 298, 299, 330, 331, 362, 363, 334, 335, 0, 0, 0,
100 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
101 0, 0, 0, 0, 0, 0, 384, 385, 386, 387, 388, 389, 390,
102 391, 392, 393, 0, 0, 0, 0, 0, 0, 400, 401, 402, 403,
103 404, 405, 406, 407, 408, 409, 0, 0, 0, 0, 0, 0, 416,
104 417, 418, 419, 420, 421, 422, 423, 424, 425, 0, 0, 0, 0,
105 0, 0, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 0,
106 0, 0, 0, 0, 0, 448, 449, 450, 451, 452, 453, 454, 455,
107 456, 457, 0, 0, 0, 0, 0, 0, 464, 465, 466, 467, 468,
108 469, 470, 471, 472, 473, 0, 0, 0, 0, 0, 0, 480, 481,
109 482, 483, 484, 485, 486, 487, 488, 489, 0, 0, 0, 0, 0,
110 0, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 0, 0,
111 0, 0, 0, 0, 394, 395, 426, 427, 458, 459, 490, 491, 462,
112 463, 0, 0, 0, 0, 0, 0, 410, 411, 442, 443, 474, 475,
113 506, 507, 478, 479, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118 0, 0, 0, 0, 0, 0, 0, 0, 0, 394, 395, 426, 427,
119 458, 459, 490, 491, 462, 463, 0, 0, 0, 0, 0, 0, 0,
120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
121 0, 0, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 0,
122 0, 0, 0, 0, 0, 528, 529, 530, 531, 532, 533, 534, 535,
123 536, 537, 0, 0, 0, 0, 0, 0, 544, 545, 546, 547, 548,
124 549, 550, 551, 552, 553, 0, 0, 0, 0, 0, 0, 560, 561,
125 562, 563, 564, 565, 566, 567, 568, 569, 0, 0, 0, 0, 0,
126 0, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 0, 0,
127 0, 0, 0, 0, 592, 593, 594, 595, 596, 597, 598, 599, 600,
128 601, 0, 0, 0, 0, 0, 0, 608, 609, 610, 611, 612, 613,
129 614, 615, 616, 617, 0, 0, 0, 0, 0, 0, 624, 625, 626,
130 627, 628, 629, 630, 631, 632, 633, 0, 0, 0, 0, 0, 0,
131 522, 523, 554, 555, 586, 587, 618, 619, 590, 591, 0, 0, 0,
132 0, 0, 0, 538, 539, 570, 571, 602, 603, 634, 635, 606, 607,
133 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
134 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
138 0, 0, 0, 0, 0, 522, 523, 554, 555, 586, 587, 618, 619,
139 590, 591, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 640, 641,
141 642, 643, 644, 645, 646, 647, 648, 649, 0, 0, 0, 0, 0,
142 0, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 0, 0,
143 0, 0, 0, 0, 672, 673, 674, 675, 676, 677, 678, 679, 680,
144 681, 0, 0, 0, 0, 0, 0, 688, 689, 690, 691, 692, 693,
145 694, 695, 696, 697, 0, 0, 0, 0, 0, 0, 704, 705, 706,
146 707, 708, 709, 710, 711, 712, 713, 0, 0, 0, 0, 0, 0,
147 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 0, 0, 0,
148 0, 0, 0, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745,
149 0, 0, 0, 0, 0, 0, 752, 753, 754, 755, 756, 757, 758,
150 759, 760, 761, 0, 0, 0, 0, 0, 0, 650, 651, 682, 683,
151 714, 715, 746, 747, 718, 719, 0, 0, 0, 0, 0, 0, 666,
152 667, 698, 699, 730, 731, 762, 763, 734, 735, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 650, 651, 682, 683, 714, 715, 746, 747, 718, 719, 0, 0,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 768, 769, 770, 771, 772, 773,
161 774, 775, 776, 777, 0, 0, 0, 0, 0, 0, 784, 785, 786,
162 787, 788, 789, 790, 791, 792, 793, 0, 0, 0, 0, 0, 0,
163 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 0, 0, 0,
164 0, 0, 0, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825,
165 0, 0, 0, 0, 0, 0, 832, 833, 834, 835, 836, 837, 838,
166 839, 840, 841, 0, 0, 0, 0, 0, 0, 848, 849, 850, 851,
167 852, 853, 854, 855, 856, 857, 0, 0, 0, 0, 0, 0, 864,
168 865, 866, 867, 868, 869, 870, 871, 872, 873, 0, 0, 0, 0,
169 0, 0, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 0,
170 0, 0, 0, 0, 0, 778, 779, 810, 811, 842, 843, 874, 875,
171 846, 847, 0, 0, 0, 0, 0, 0, 794, 795, 826, 827, 858,
172 859, 890, 891, 862, 863, 0, 0, 0, 0, 0, 0, 0, 0,
173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 778, 779, 810,
178 811, 842, 843, 874, 875, 846, 847, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905,
181 0, 0, 0, 0, 0, 0, 912, 913, 914, 915, 916, 917, 918,
182 919, 920, 921, 0, 0, 0, 0, 0, 0, 928, 929, 930, 931,
183 932, 933, 934, 935, 936, 937, 0, 0, 0, 0, 0, 0, 944,
184 945, 946, 947, 948, 949, 950, 951, 952, 953, 0, 0, 0, 0,
185 0, 0, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 0,
186 0, 0, 0, 0, 0, 976, 977, 978, 979, 980, 981, 982, 983,
187 984, 985, 0, 0, 0, 0, 0, 0, 992, 993, 994, 995, 996,
188 997, 998, 999, 1000, 1001, 0, 0, 0, 0, 0, 0, 1008, 1009,
189 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 0, 0, 0, 0, 0,
190 0, 906, 907, 938, 939, 970, 971, 1002, 1003, 974, 975, 0, 0,
191 0, 0, 0, 0, 922, 923, 954, 955, 986, 987, 1018, 1019, 990,
192 991, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
193 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
194 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
195 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
196 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
197 0, 0, 0, 0, 0, 0, 906, 907, 938, 939, 970, 971, 1002,
198 1003, 974, 975, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
199 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12,
200 13, 268, 269, 524, 525, 780, 781, 46, 47, 0, 0, 0, 0,
201 0, 0, 28, 29, 284, 285, 540, 541, 796, 797, 62, 63, 0,
202 0, 0, 0, 0, 0, 44, 45, 300, 301, 556, 557, 812, 813,
203 302, 303, 0, 0, 0, 0, 0, 0, 60, 61, 316, 317, 572,
204 573, 828, 829, 318, 319, 0, 0, 0, 0, 0, 0, 76, 77,
205 332, 333, 588, 589, 844, 845, 558, 559, 0, 0, 0, 0, 0,
206 0, 92, 93, 348, 349, 604, 605, 860, 861, 574, 575, 0, 0,
207 0, 0, 0, 0, 108, 109, 364, 365, 620, 621, 876, 877, 814,
208 815, 0, 0, 0, 0, 0, 0, 124, 125, 380, 381, 636, 637,
209 892, 893, 830, 831, 0, 0, 0, 0, 0, 0, 14, 15, 270,
210 271, 526, 527, 782, 783, 110, 111, 0, 0, 0, 0, 0, 0,
211 30, 31, 286, 287, 542, 543, 798, 799, 126, 127, 0, 0, 0,
212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
216 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
217 0, 0, 14, 15, 270, 271, 526, 527, 782, 783, 110, 111, 0,
218 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
219 0, 0, 0, 0, 0, 0, 0, 0, 140, 141, 396, 397, 652,
220 653, 908, 909, 174, 175, 0, 0, 0, 0, 0, 0, 156, 157,
221 412, 413, 668, 669, 924, 925, 190, 191, 0, 0, 0, 0, 0,
222 0, 172, 173, 428, 429, 684, 685, 940, 941, 430, 431, 0, 0,
223 0, 0, 0, 0, 188, 189, 444, 445, 700, 701, 956, 957, 446,
224 447, 0, 0, 0, 0, 0, 0, 204, 205, 460, 461, 716, 717,
225 972, 973, 686, 687, 0, 0, 0, 0, 0, 0, 220, 221, 476,
226 477, 732, 733, 988, 989, 702, 703, 0, 0, 0, 0, 0, 0,
227 236, 237, 492, 493, 748, 749, 1004, 1005, 942, 943, 0, 0, 0,
228 0, 0, 0, 252, 253, 508, 509, 764, 765, 1020, 1021, 958, 959,
229 0, 0, 0, 0, 0, 0, 142, 143, 398, 399, 654, 655, 910,
230 911, 238, 239, 0, 0, 0, 0, 0, 0, 158, 159, 414, 415,
231 670, 671, 926, 927, 254, 255
237 const uint16_t DPD2BCD
[1024] = { 0, 1, 2, 3, 4, 5, 6, 7,
238 8, 9, 128, 129, 2048, 2049, 2176, 2177, 16, 17, 18, 19, 20,
239 21, 22, 23, 24, 25, 144, 145, 2064, 2065, 2192, 2193, 32, 33,
240 34, 35, 36, 37, 38, 39, 40, 41, 130, 131, 2080, 2081, 2056,
241 2057, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 146, 147,
242 2096, 2097, 2072, 2073, 64, 65, 66, 67, 68, 69, 70, 71, 72,
243 73, 132, 133, 2112, 2113, 136, 137, 80, 81, 82, 83, 84, 85,
244 86, 87, 88, 89, 148, 149, 2128, 2129, 152, 153, 96, 97, 98,
245 99, 100, 101, 102, 103, 104, 105, 134, 135, 2144, 2145, 2184, 2185,
246 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 150, 151, 2160,
247 2161, 2200, 2201, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
248 384, 385, 2304, 2305, 2432, 2433, 272, 273, 274, 275, 276, 277, 278,
249 279, 280, 281, 400, 401, 2320, 2321, 2448, 2449, 288, 289, 290, 291,
250 292, 293, 294, 295, 296, 297, 386, 387, 2336, 2337, 2312, 2313, 304,
251 305, 306, 307, 308, 309, 310, 311, 312, 313, 402, 403, 2352, 2353,
252 2328, 2329, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 388,
253 389, 2368, 2369, 392, 393, 336, 337, 338, 339, 340, 341, 342, 343,
254 344, 345, 404, 405, 2384, 2385, 408, 409, 352, 353, 354, 355, 356,
255 357, 358, 359, 360, 361, 390, 391, 2400, 2401, 2440, 2441, 368, 369,
256 370, 371, 372, 373, 374, 375, 376, 377, 406, 407, 2416, 2417, 2456,
257 2457, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 640, 641,
258 2050, 2051, 2178, 2179, 528, 529, 530, 531, 532, 533, 534, 535, 536,
259 537, 656, 657, 2066, 2067, 2194, 2195, 544, 545, 546, 547, 548, 549,
260 550, 551, 552, 553, 642, 643, 2082, 2083, 2088, 2089, 560, 561, 562,
261 563, 564, 565, 566, 567, 568, 569, 658, 659, 2098, 2099, 2104, 2105,
262 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 644, 645, 2114,
263 2115, 648, 649, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601,
264 660, 661, 2130, 2131, 664, 665, 608, 609, 610, 611, 612, 613, 614,
265 615, 616, 617, 646, 647, 2146, 2147, 2184, 2185, 624, 625, 626, 627,
266 628, 629, 630, 631, 632, 633, 662, 663, 2162, 2163, 2200, 2201, 768,
267 769, 770, 771, 772, 773, 774, 775, 776, 777, 896, 897, 2306, 2307,
268 2434, 2435, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 912,
269 913, 2322, 2323, 2450, 2451, 800, 801, 802, 803, 804, 805, 806, 807,
270 808, 809, 898, 899, 2338, 2339, 2344, 2345, 816, 817, 818, 819, 820,
271 821, 822, 823, 824, 825, 914, 915, 2354, 2355, 2360, 2361, 832, 833,
272 834, 835, 836, 837, 838, 839, 840, 841, 900, 901, 2370, 2371, 904,
273 905, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 916, 917,
274 2386, 2387, 920, 921, 864, 865, 866, 867, 868, 869, 870, 871, 872,
275 873, 902, 903, 2402, 2403, 2440, 2441, 880, 881, 882, 883, 884, 885,
276 886, 887, 888, 889, 918, 919, 2418, 2419, 2456, 2457, 1024, 1025, 1026,
277 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1152, 1153, 2052, 2053, 2180,
279 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1168, 1169,
281 2069, 2196, 2197, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064,
283 1154, 1155, 2084, 2085, 2120, 2121, 1072, 1073, 1074, 1075, 1076, 1077,
285 1079, 1080, 1081, 1170, 1171, 2100, 2101, 2136, 2137, 1088, 1089, 1090,
287 1092, 1093, 1094, 1095, 1096, 1097, 1156, 1157, 2116, 2117, 1160, 1161,
289 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1172, 1173, 2132,
291 1176, 1177, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129,
293 1159, 2148, 2149, 2184, 2185, 1136, 1137, 1138, 1139, 1140, 1141, 1142,
295 1144, 1145, 1174, 1175, 2164, 2165, 2200, 2201, 1280, 1281, 1282, 1283,
297 1285, 1286, 1287, 1288, 1289, 1408, 1409, 2308, 2309, 2436, 2437, 1296,
299 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1424, 1425, 2324, 2325,
301 2453, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1410,
303 2340, 2341, 2376, 2377, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335,
305 1337, 1426, 1427, 2356, 2357, 2392, 2393, 1344, 1345, 1346, 1347, 1348,
307 1350, 1351, 1352, 1353, 1412, 1413, 2372, 2373, 1416, 1417, 1360, 1361,
309 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1428, 1429, 2388, 2389, 1432,
311 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1414, 1415,
313 2405, 2440, 2441, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400,
315 1430, 1431, 2420, 2421, 2456, 2457, 1536, 1537, 1538, 1539, 1540, 1541,
317 1543, 1544, 1545, 1664, 1665, 2054, 2055, 2182, 2183, 1552, 1553, 1554,
319 1556, 1557, 1558, 1559, 1560, 1561, 1680, 1681, 2070, 2071, 2198, 2199,
321 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1666, 1667, 2086,
323 2152, 2153, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593,
325 1683, 2102, 2103, 2168, 2169, 1600, 1601, 1602, 1603, 1604, 1605, 1606,
327 1608, 1609, 1668, 1669, 2118, 2119, 1672, 1673, 1616, 1617, 1618, 1619,
329 1621, 1622, 1623, 1624, 1625, 1684, 1685, 2134, 2135, 1688, 1689, 1632,
331 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1670, 1671, 2150, 2151,
333 2185, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1686,
335 2166, 2167, 2200, 2201, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799,
337 1801, 1920, 1921, 2310, 2311, 2438, 2439, 1808, 1809, 1810, 1811, 1812,
339 1814, 1815, 1816, 1817, 1936, 1937, 2326, 2327, 2454, 2455, 1824, 1825,
341 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1922, 1923, 2342, 2343, 2408,
343 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1938, 1939,
345 2359, 2424, 2425, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864,
347 1924, 1925, 2374, 2375, 1928, 1929, 1872, 1873, 1874, 1875, 1876, 1877,
349 1879, 1880, 1881, 1940, 1941, 2390, 2391, 1944, 1945, 1888, 1889, 1890,
351 1892, 1893, 1894, 1895, 1896, 1897, 1926, 1927, 2406, 2407, 2440, 2441,
353 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1942, 1943, 2422,
361 const uint16_t BIN2DPD
[1000] = { 0, 1, 2, 3, 4, 5, 6, 7,
362 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32,
363 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51,
364 52, 53, 54, 55, 56, 57, 64, 65, 66, 67, 68, 69, 70,
365 71, 72, 73, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
366 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 112, 113, 114,
367 115, 116, 117, 118, 119, 120, 121, 10, 11, 42, 43, 74, 75,
368 106, 107, 78, 79, 26, 27, 58, 59, 90, 91, 122, 123, 94,
369 95, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 144, 145,
370 146, 147, 148, 149, 150, 151, 152, 153, 160, 161, 162, 163, 164,
371 165, 166, 167, 168, 169, 176, 177, 178, 179, 180, 181, 182, 183,
372 184, 185, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 208,
373 209, 210, 211, 212, 213, 214, 215, 216, 217, 224, 225, 226, 227,
374 228, 229, 230, 231, 232, 233, 240, 241, 242, 243, 244, 245, 246,
375 247, 248, 249, 138, 139, 170, 171, 202, 203, 234, 235, 206, 207,
376 154, 155, 186, 187, 218, 219, 250, 251, 222, 223, 256, 257, 258,
377 259, 260, 261, 262, 263, 264, 265, 272, 273, 274, 275, 276, 277,
378 278, 279, 280, 281, 288, 289, 290, 291, 292, 293, 294, 295, 296,
379 297, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 320, 321,
380 322, 323, 324, 325, 326, 327, 328, 329, 336, 337, 338, 339, 340,
381 341, 342, 343, 344, 345, 352, 353, 354, 355, 356, 357, 358, 359,
382 360, 361, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 266,
383 267, 298, 299, 330, 331, 362, 363, 334, 335, 282, 283, 314, 315,
384 346, 347, 378, 379, 350, 351, 384, 385, 386, 387, 388, 389, 390,
385 391, 392, 393, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
386 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 432, 433, 434,
387 435, 436, 437, 438, 439, 440, 441, 448, 449, 450, 451, 452, 453,
388 454, 455, 456, 457, 464, 465, 466, 467, 468, 469, 470, 471, 472,
389 473, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 496, 497,
390 498, 499, 500, 501, 502, 503, 504, 505, 394, 395, 426, 427, 458,
391 459, 490, 491, 462, 463, 410, 411, 442, 443, 474, 475, 506, 507,
392 478, 479, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 528,
393 529, 530, 531, 532, 533, 534, 535, 536, 537, 544, 545, 546, 547,
394 548, 549, 550, 551, 552, 553, 560, 561, 562, 563, 564, 565, 566,
395 567, 568, 569, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585,
396 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 608, 609, 610,
397 611, 612, 613, 614, 615, 616, 617, 624, 625, 626, 627, 628, 629,
398 630, 631, 632, 633, 522, 523, 554, 555, 586, 587, 618, 619, 590,
399 591, 538, 539, 570, 571, 602, 603, 634, 635, 606, 607, 640, 641,
400 642, 643, 644, 645, 646, 647, 648, 649, 656, 657, 658, 659, 660,
401 661, 662, 663, 664, 665, 672, 673, 674, 675, 676, 677, 678, 679,
402 680, 681, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 704,
403 705, 706, 707, 708, 709, 710, 711, 712, 713, 720, 721, 722, 723,
404 724, 725, 726, 727, 728, 729, 736, 737, 738, 739, 740, 741, 742,
405 743, 744, 745, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761,
406 650, 651, 682, 683, 714, 715, 746, 747, 718, 719, 666, 667, 698,
407 699, 730, 731, 762, 763, 734, 735, 768, 769, 770, 771, 772, 773,
408 774, 775, 776, 777, 784, 785, 786, 787, 788, 789, 790, 791, 792,
409 793, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 816, 817,
410 818, 819, 820, 821, 822, 823, 824, 825, 832, 833, 834, 835, 836,
411 837, 838, 839, 840, 841, 848, 849, 850, 851, 852, 853, 854, 855,
412 856, 857, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 880,
413 881, 882, 883, 884, 885, 886, 887, 888, 889, 778, 779, 810, 811,
414 842, 843, 874, 875, 846, 847, 794, 795, 826, 827, 858, 859, 890,
415 891, 862, 863, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905,
416 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 928, 929, 930,
417 931, 932, 933, 934, 935, 936, 937, 944, 945, 946, 947, 948, 949,
418 950, 951, 952, 953, 960, 961, 962, 963, 964, 965, 966, 967, 968,
419 969, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 992, 993,
420 994, 995, 996, 997, 998, 999, 1000, 1001, 1008, 1009, 1010, 1011, 1012,
421 1013, 1014, 1015, 1016, 1017, 906, 907, 938, 939, 970, 971, 1002, 1003,
422 974, 975, 922, 923, 954, 955, 986, 987, 1018, 1019, 990, 991, 12,
423 13, 268, 269, 524, 525, 780, 781, 46, 47, 28, 29, 284, 285,
424 540, 541, 796, 797, 62, 63, 44, 45, 300, 301, 556, 557, 812,
425 813, 302, 303, 60, 61, 316, 317, 572, 573, 828, 829, 318, 319,
426 76, 77, 332, 333, 588, 589, 844, 845, 558, 559, 92, 93, 348,
427 349, 604, 605, 860, 861, 574, 575, 108, 109, 364, 365, 620, 621,
428 876, 877, 814, 815, 124, 125, 380, 381, 636, 637, 892, 893, 830,
429 831, 14, 15, 270, 271, 526, 527, 782, 783, 110, 111, 30, 31,
430 286, 287, 542, 543, 798, 799, 126, 127, 140, 141, 396, 397, 652,
431 653, 908, 909, 174, 175, 156, 157, 412, 413, 668, 669, 924, 925,
432 190, 191, 172, 173, 428, 429, 684, 685, 940, 941, 430, 431, 188,
433 189, 444, 445, 700, 701, 956, 957, 446, 447, 204, 205, 460, 461,
434 716, 717, 972, 973, 686, 687, 220, 221, 476, 477, 732, 733, 988,
435 989, 702, 703, 236, 237, 492, 493, 748, 749, 1004, 1005, 942, 943,
436 252, 253, 508, 509, 764, 765, 1020, 1021, 958, 959, 142, 143, 398,
437 399, 654, 655, 910, 911, 238, 239, 158, 159, 414, 415, 670, 671,
444 const uint16_t DPD2BIN
[1024] = { 0, 1, 2, 3, 4, 5, 6, 7,
445 8, 9, 80, 81, 800, 801, 880, 881, 10, 11, 12, 13, 14,
446 15, 16, 17, 18, 19, 90, 91, 810, 811, 890, 891, 20, 21,
447 22, 23, 24, 25, 26, 27, 28, 29, 82, 83, 820, 821, 808,
448 809, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 92, 93,
449 830, 831, 818, 819, 40, 41, 42, 43, 44, 45, 46, 47, 48,
450 49, 84, 85, 840, 841, 88, 89, 50, 51, 52, 53, 54, 55,
451 56, 57, 58, 59, 94, 95, 850, 851, 98, 99, 60, 61, 62,
452 63, 64, 65, 66, 67, 68, 69, 86, 87, 860, 861, 888, 889,
453 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 96, 97, 870,
454 871, 898, 899, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
455 180, 181, 900, 901, 980, 981, 110, 111, 112, 113, 114, 115, 116,
456 117, 118, 119, 190, 191, 910, 911, 990, 991, 120, 121, 122, 123,
457 124, 125, 126, 127, 128, 129, 182, 183, 920, 921, 908, 909, 130,
458 131, 132, 133, 134, 135, 136, 137, 138, 139, 192, 193, 930, 931,
459 918, 919, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 184,
460 185, 940, 941, 188, 189, 150, 151, 152, 153, 154, 155, 156, 157,
461 158, 159, 194, 195, 950, 951, 198, 199, 160, 161, 162, 163, 164,
462 165, 166, 167, 168, 169, 186, 187, 960, 961, 988, 989, 170, 171,
463 172, 173, 174, 175, 176, 177, 178, 179, 196, 197, 970, 971, 998,
464 999, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 280, 281,
465 802, 803, 882, 883, 210, 211, 212, 213, 214, 215, 216, 217, 218,
466 219, 290, 291, 812, 813, 892, 893, 220, 221, 222, 223, 224, 225,
467 226, 227, 228, 229, 282, 283, 822, 823, 828, 829, 230, 231, 232,
468 233, 234, 235, 236, 237, 238, 239, 292, 293, 832, 833, 838, 839,
469 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 284, 285, 842,
470 843, 288, 289, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259,
471 294, 295, 852, 853, 298, 299, 260, 261, 262, 263, 264, 265, 266,
472 267, 268, 269, 286, 287, 862, 863, 888, 889, 270, 271, 272, 273,
473 274, 275, 276, 277, 278, 279, 296, 297, 872, 873, 898, 899, 300,
474 301, 302, 303, 304, 305, 306, 307, 308, 309, 380, 381, 902, 903,
475 982, 983, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 390,
476 391, 912, 913, 992, 993, 320, 321, 322, 323, 324, 325, 326, 327,
477 328, 329, 382, 383, 922, 923, 928, 929, 330, 331, 332, 333, 334,
478 335, 336, 337, 338, 339, 392, 393, 932, 933, 938, 939, 340, 341,
479 342, 343, 344, 345, 346, 347, 348, 349, 384, 385, 942, 943, 388,
480 389, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 394, 395,
481 952, 953, 398, 399, 360, 361, 362, 363, 364, 365, 366, 367, 368,
482 369, 386, 387, 962, 963, 988, 989, 370, 371, 372, 373, 374, 375,
483 376, 377, 378, 379, 396, 397, 972, 973, 998, 999, 400, 401, 402,
484 403, 404, 405, 406, 407, 408, 409, 480, 481, 804, 805, 884, 885,
485 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 490, 491, 814,
486 815, 894, 895, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429,
487 482, 483, 824, 825, 848, 849, 430, 431, 432, 433, 434, 435, 436,
488 437, 438, 439, 492, 493, 834, 835, 858, 859, 440, 441, 442, 443,
489 444, 445, 446, 447, 448, 449, 484, 485, 844, 845, 488, 489, 450,
490 451, 452, 453, 454, 455, 456, 457, 458, 459, 494, 495, 854, 855,
491 498, 499, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 486,
492 487, 864, 865, 888, 889, 470, 471, 472, 473, 474, 475, 476, 477,
493 478, 479, 496, 497, 874, 875, 898, 899, 500, 501, 502, 503, 504,
494 505, 506, 507, 508, 509, 580, 581, 904, 905, 984, 985, 510, 511,
495 512, 513, 514, 515, 516, 517, 518, 519, 590, 591, 914, 915, 994,
496 995, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 582, 583,
497 924, 925, 948, 949, 530, 531, 532, 533, 534, 535, 536, 537, 538,
498 539, 592, 593, 934, 935, 958, 959, 540, 541, 542, 543, 544, 545,
499 546, 547, 548, 549, 584, 585, 944, 945, 588, 589, 550, 551, 552,
500 553, 554, 555, 556, 557, 558, 559, 594, 595, 954, 955, 598, 599,
501 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 586, 587, 964,
502 965, 988, 989, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579,
503 596, 597, 974, 975, 998, 999, 600, 601, 602, 603, 604, 605, 606,
504 607, 608, 609, 680, 681, 806, 807, 886, 887, 610, 611, 612, 613,
505 614, 615, 616, 617, 618, 619, 690, 691, 816, 817, 896, 897, 620,
506 621, 622, 623, 624, 625, 626, 627, 628, 629, 682, 683, 826, 827,
507 868, 869, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 692,
508 693, 836, 837, 878, 879, 640, 641, 642, 643, 644, 645, 646, 647,
509 648, 649, 684, 685, 846, 847, 688, 689, 650, 651, 652, 653, 654,
510 655, 656, 657, 658, 659, 694, 695, 856, 857, 698, 699, 660, 661,
511 662, 663, 664, 665, 666, 667, 668, 669, 686, 687, 866, 867, 888,
512 889, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 696, 697,
513 876, 877, 898, 899, 700, 701, 702, 703, 704, 705, 706, 707, 708,
514 709, 780, 781, 906, 907, 986, 987, 710, 711, 712, 713, 714, 715,
515 716, 717, 718, 719, 790, 791, 916, 917, 996, 997, 720, 721, 722,
516 723, 724, 725, 726, 727, 728, 729, 782, 783, 926, 927, 968, 969,
517 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 792, 793, 936,
518 937, 978, 979, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749,
519 784, 785, 946, 947, 788, 789, 750, 751, 752, 753, 754, 755, 756,
520 757, 758, 759, 794, 795, 956, 957, 798, 799, 760, 761, 762, 763,
521 764, 765, 766, 767, 768, 769, 786, 787, 966, 967, 988, 989, 770,
522 771, 772, 773, 774, 775, 776, 777, 778, 779, 796, 797, 976, 977,