aboutsummaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
Diffstat (limited to 'example.c')
-rw-r--r--example.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/example.c b/example.c
index 420264a..7d7ee94 100644
--- a/example.c
+++ b/example.c
@@ -43,13 +43,9 @@ 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;
- }
+ BigInt a = B_newstr(&g, "0"),
+ b = B_newstr(&g, "1");
+ printf("a takes up %lu bits\n", B_bits(a));
B_sum(&a, b);
char *astr = B_tostr(&g, a);
@@ -58,15 +54,15 @@ main() {
B_sub(&a, b);
B_sub(&a, b);
astr = B_tostr(&g, a);
- printf("a - b = %s\n", astr);
+ printf("a - b = %s\t(%lu bits)\n", astr, B_bits(a));
- B_lshift(&a, 30);
+ B_lshift(&a, 65);
astr = B_tostr(&g, a);
- printf("a << 30 = %s\n", astr);
+ printf("a << 65 = %s (%d)\n", astr, B_gt(a, b));
- B_rshift(&a, 30);
+ B_rshift(&a, 65);
astr = B_tostr(&g, a);
- printf("a >> 30 = %s\n", astr);
+ printf("a >> 65 = %s\n", astr);
BigInt c = B_newstr(&g, "12345678901234567890123");
astr = B_tostr(&g, c);