diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-08-02 02:07:14 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-08-11 20:59:52 +0200 |
| commit | cd0ce7b76e800ac308d6df02ddad4da221fbb90a (patch) | |
| tree | f58e537afcbe609d1cf31071e86323cc5f1b36fa /core/math/big/example.odin | |
| parent | 320387c4ee07a3e38c4d2b80c37a57e8b1436e12 (diff) | |
big: Add `choose`.
Diffstat (limited to 'core/math/big/example.odin')
| -rw-r--r-- | core/math/big/example.odin | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/core/math/big/example.odin b/core/math/big/example.odin index 5452dd711..14531a184 100644 --- a/core/math/big/example.odin +++ b/core/math/big/example.odin @@ -54,7 +54,7 @@ print_timings :: proc() { case avg < time.Millisecond: avg_s = fmt.tprintf("%v µs", time.duration_microseconds(avg)); case: - avg_s = fmt.tprintf("%v", time.duration_milliseconds(avg)); + avg_s = fmt.tprintf("%v ms", time.duration_milliseconds(avg)); } total_s: string; @@ -64,7 +64,7 @@ print_timings :: proc() { case v.t < time.Millisecond: total_s = fmt.tprintf("%v µs", time.duration_microseconds(v.t)); case: - total_s = fmt.tprintf("%v", time.duration_milliseconds(v.t)); + total_s = fmt.tprintf("%v ms", time.duration_milliseconds(v.t)); } fmt.printf("\t%v: %s (avg), %s (total, %v calls)\n", i, avg_s, total_s, v.c); @@ -76,6 +76,7 @@ Category :: enum { itoa, atoi, factorial, + choose, lsb, ctz, }; @@ -114,30 +115,11 @@ demo :: proc() { a, b, c, d, e, f := &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{}; defer destroy(a, b, c, d, e, f); - set(a, 125); - set(b, 75); - - err = gcd_lcm(c, d, a, b); - fmt.printf("gcd_lcm("); - print("a =", a, 10, false, true, false); - print(", b =", b, 10, false, true, false); - print("), gcd =", c, 10, false, true, false); - print(", lcm =", d, 10, false, true, false); - fmt.printf(" (err = %v)\n", err); - - err = gcd(c, a, b); - fmt.printf("gcd("); - print("a =", a, 10, false, true, false); - print(", b =", b, 10, false, true, false); - print(") =", c, 10, false, true, false); - fmt.printf(" (err = %v)\n", err); - - err = lcm(c, a, b); - fmt.printf("lcm("); - print("a =", a, 10, false, true, false); - print(", b =", b, 10, false, true, false); - print(") =", c, 10, false, true, false); - fmt.printf(" (err = %v)\n", err); + s := time.tick_now(); + err = choose(a, 65535, 255); + Timings[.choose].t += time.tick_since(s); Timings[.choose].c += 1; + print("choose", a); + fmt.println(err); } main :: proc() { |