summaryrefslogtreecommitdiffstats
path: root/test.c
blob: e2ecc404a86c3471ef0dc0dc57768891a4a252af (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 "mpn.h"

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

    m = mpn_int(5);
    i = 5;

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

	i *= 5;
	m = mpn_mul(m, mpn_int(5));
    }
    mpn_free(m);

    m = mpn_int(5);
    i = 5;
    n = nx;
    while (n--) {
	printf("%016"PRIx64" : ", i);
	mpn_dump(stdout, mpn_ref(m));
	putchar('\n');

	i += i;
	m = mpn_add(m, mpn_ref(m));
    }

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

	i -= j;
	j += j;
	m = mpn_sub(m, mpn_ref(mj));
	mj = mpn_add(mj, mpn_ref(mj));
    }

    return 0;
}