diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-08-03 19:52:14 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-08-11 20:59:52 +0200 |
| commit | fc0a92f8ace0e8a6f42d7666b8d4cb92cfb0df3e (patch) | |
| tree | be538620846e073e70fca1d4accf320603ac94d1 /core/math/big/example.odin | |
| parent | 97d80d03f9902872bcd12e460822dce70e6d3fd1 (diff) | |
big: Add constants.
Diffstat (limited to 'core/math/big/example.odin')
| -rw-r--r-- | core/math/big/example.odin | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/core/math/big/example.odin b/core/math/big/example.odin index 7dc6329c6..96d036570 100644 --- a/core/math/big/example.odin +++ b/core/math/big/example.odin @@ -39,6 +39,7 @@ _SQR_KARATSUBA_CUTOFF, _MUL_TOOM_CUTOFF, _SQR_TOOM_CUTOFF, ); + } print_timings :: proc() { @@ -95,16 +96,15 @@ print :: proc(name: string, a: ^Int, base := i8(10), print_name := false, newlin defer delete(as); cb, _ := count_bits(a); if print_name { - fmt.printf("%v ", name); - } - if print_extra_info { - fmt.printf("(base: %v, bits used: %v): %v", base, cb, as); - } else { - fmt.printf("%v", as); + fmt.printf("%v", name); } if err != nil { fmt.printf("%v (error: %v | %v)", name, err, a); } + fmt.printf("%v", as); + if print_extra_info { + fmt.printf(" (base: %v, bits used: %v, flags: %v)", base, cb, a.flags); + } if newline { fmt.println(); } @@ -118,6 +118,31 @@ demo :: proc() { a, b, c, d, e, f := &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{}; defer destroy(a, b, c, d, e, f); + fmt.println(); + print(" ONE: ", ONE, 10, true, true, true); + fmt.println(); + + one(a); + print(" one: ", a, 10, true, true, true); + fmt.println(); + + minus_one(a); + print("-one: ", a, 10, true, true, true); + fmt.println(); + + nan(a); + print(" nan: ", a, 10, true, true, true); + fmt.println(); + + inf(a); + print(" inf: ", a, 10, true, true, true); + fmt.println(); + + minus_inf(a); + print("-inf: ", a, 10, true, true, true); + fmt.println(); + + factorial(a, 128); // Untimed warmup. N :: 128; @@ -145,8 +170,8 @@ main :: proc() { mem.tracking_allocator_init(&ta, context.allocator); context.allocator = mem.tracking_allocator(&ta); - // print_configation(); demo(); + print_timings(); if len(ta.allocation_map) > 0 { |