1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3 #ident "$Id$"
4 /*======
5 This file is part of TokuDB
6
7
8 Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9
10 TokuDBis is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License, version 2,
12 as published by the Free Software Foundation.
13
14 TokuDB is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with TokuDB. If not, see <http://www.gnu.org/licenses/>.
21
22 ======= */
23
24 #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
25
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <inttypes.h>
29 #include <stdlib.h>
30 #include <sys/types.h>
31
32 #include <tokudb_math.h>
33 using namespace tokudb;
34
test(int length_bits)35 static void test(int length_bits) {
36 printf("%s %d\n", __FUNCTION__, length_bits);
37 uint64_t max = (1ULL << length_bits) - 1;
38 for (uint64_t x = 0; x <= max; x++) {
39 for (uint64_t y = 0; y <= max; y++) {
40 bool over;
41 uint64_t n = uint_add(x, y, max, &over);
42 printf("%"PRIu64" %"PRIu64" %"PRIu64"\n", x, y, n);
43 }
44 }
45 }
46
main(int argc,char * argv[])47 int main(int argc, char *argv[]) {
48 if (argc > 1) {
49 for (int i = 1; i < argc; i++) {
50 test(atoi(argv[i]));
51 }
52 }
53 return 0;
54 }
55