aboutsummaryrefslogtreecommitdiff
path: root/core/math/big/example.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-08-11 00:37:34 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-08-11 20:59:54 +0200
commit2b274fefbb214533399b804acce8977ecaa3afeb (patch)
treefb994e586fba8b29886977f0dbf5a1afe0b9f132 /core/math/big/example.odin
parent6c681b258c7118b4a6aa7bf27af38f5556ad7599 (diff)
big: Add `_private_int_sqr_karatsuba`.
Diffstat (limited to 'core/math/big/example.odin')
-rw-r--r--core/math/big/example.odin19
1 files changed, 15 insertions, 4 deletions
diff --git a/core/math/big/example.odin b/core/math/big/example.odin
index 3d51ac400..1d9a4cb3c 100644
--- a/core/math/big/example.odin
+++ b/core/math/big/example.odin
@@ -80,16 +80,27 @@ demo :: proc() {
err: Error;
bs: string;
- if err = factorial(a, 500); err != nil { fmt.printf("factorial err: %v\n", err); return; }
+ // if err = factorial(a, 850); err != nil { fmt.printf("factorial err: %v\n", err); return; }
+
+ foo := "615037959146039477924633848896619112832171971562900618409305032006863881436080";
+ if err = atoi(a, foo, 10); err != nil { return; }
+ print("a: ", a, 10, true, true, true);
+ fmt.println();
+
{
SCOPED_TIMING(.sqr);
- if err = sqr(b, a); err != nil { fmt.printf("sqr err: %v\n", err); return; }
+ if err = sqr(b, a); err != nil { fmt.printf("sqr err: %v\n", err); return; }
}
+ fmt.println();
+ print("b _sqr_karatsuba: ", b);
+ fmt.println();
- bs, err = itoa(b, 10);
+ bs, err = itoa(b, 16);
defer delete(bs);
- assert(bs[:50] == "14887338741396604108836218987068397819515734169330");
+ if bs[:50] != "1C367982F3050A8A3C62A8A7906D165438B54B287AF3F15D36" {
+ fmt.println("sqr failed");
+ }
}
main :: proc() {