summaryrefslogtreecommitdiffstats
path: root/test.c
blob: 00a5ddf9a6711b4a7c6c930cdfafc7199c5321c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
#include "pbn.h"

int main(int argc, char *argv[])
{
    uint64_t i, j;
    struct pbn *m, *mj;
    int nx = (argc < 2) ? 64 : atoi(argv[1]);
    int n;

    m = pbn_int(5);
    i = 5;

    n = nx;
    while (n--) {
	printf("%016"PRIx64" : ", i);
	pbn_dump(stdout, pbn_ref(m));
	putchar('\n');

	i *= 5;
	m = pbn_mul(m, pbn_int(5));
    }
    pbn_free(m);

    m = pbn_int(5);
    i = 5;
    n = nx;
    while (n--) {
	printf("%016"PRIx64" : ", i);
	pbn_dump(stdout, pbn_ref(m));
	putchar('\n');

	i += i;
	m = pbn_add(m, pbn_ref(m));
    }

    n = nx;
    j = 20;
    mj = pbn_int(20);
    while (n--) {
	printf("%016"PRIx64" : ", i);
	pbn_dump(stdout, pbn_ref(m));
	printf(" : ");
	pbn_dump(stdout, pbn_ref(mj));
	putchar('\n');

	i -= j;
	j += j;
	m = pbn_sub(m, pbn_ref(mj));
	mj = pbn_add(mj, pbn_ref(mj));
    }

    return 0;
}