aboutsummaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
Diffstat (limited to 'example.c')
-rw-r--r--example.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/example.c b/example.c
index 6dc3525..52d402e 100644
--- a/example.c
+++ b/example.c
@@ -3,6 +3,7 @@
#include "Vector.h"
#include "String.h"
#include "BumpAlloc.h"
+#include "BigInt.h"
#include <stdio.h>
int
@@ -42,6 +43,31 @@ main() {
PRINT_NOTOK(H_freevals(&tet));
PRINT_NOTOK(H_free(&tet));
+ BigInt a = B_new(&g, -1),
+ b = B_new(&g, 1);
+
+ {
+ uint_fast32_t *aa = a;
+ aa[0] = -1;
+ }
+
+ B_sum(&a, b);
+ char *astr = B_tostr(&g, a);
+ printf("a + b = %s\n", astr);
+
+ B_sub(&a, b);
+ B_sub(&a, b);
+ astr = B_tostr(&g, a);
+ printf("a - b = %s\n", astr);
+
+ B_lshift(&a, 30);
+ astr = B_tostr(&g, a);
+ printf("a << 30 = %s\n", astr);
+
+ B_rshift(&a, 30);
+ astr = B_tostr(&g, a);
+ printf("a >> 30 = %s\n", astr);
+
PRINT_NOTOK(g.destroy(&g));
PRINT_NOTOK(t.destroy(&t));
PRINT_NOTOK(T.destroy(&T));