diff options
| author | Syndamia <kamen@syndamia.com> | 2026-05-23 09:56:17 +0300 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2026-05-23 09:56:17 +0300 |
| commit | 7e0b603b78adf4c1704b757da05d085e03afe5f6 (patch) | |
| tree | 558a05e8ca9c0c7cd2bd27df9d9ed0404f4c66d6 /example.c | |
| parent | 72f791227cf3f0e835e62ff22953c005a40882c6 (diff) | |
| download | foollib-7e0b603b78adf4c1704b757da05d085e03afe5f6.tar foollib-7e0b603b78adf4c1704b757da05d085e03afe5f6.tar.gz foollib-7e0b603b78adf4c1704b757da05d085e03afe5f6.zip | |
feat(BigInt): Implement bit shifts and add math in example
Diffstat (limited to 'example.c')
| -rw-r--r-- | example.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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)); |
