From 7e0b603b78adf4c1704b757da05d085e03afe5f6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 23 May 2026 09:56:17 +0300 Subject: feat(BigInt): Implement bit shifts and add math in example --- example.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'example.c') 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 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)); -- cgit v1.2.3