aboutsummaryrefslogtreecommitdiff
path: root/core/math/big/helpers.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-08-02 17:47:07 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-08-11 20:59:52 +0200
commit491e4ecc740a361bd726f8caf92f8eed078ed333 (patch)
tree216f38088769fa48759ebe0561c777192f1b95d3 /core/math/big/helpers.odin
parentcd0ce7b76e800ac308d6df02ddad4da221fbb90a (diff)
big: Add binary split factorial.
Diffstat (limited to 'core/math/big/helpers.odin')
-rw-r--r--core/math/big/helpers.odin16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/math/big/helpers.odin b/core/math/big/helpers.odin
index dc846b4b9..a3b4f13ba 100644
--- a/core/math/big/helpers.odin
+++ b/core/math/big/helpers.odin
@@ -337,9 +337,7 @@ zero :: clear;
Set the `Int` to 1 and optionally shrink it to the minimum backing size.
*/
int_one :: proc(a: ^Int, minimize := false, allocator := context.allocator) -> (err: Error) {
- if err = clear(a, minimize, allocator); err != .None {
- return err;
- }
+ if err = clear(a, minimize, allocator); err != .None { return err; }
a.used = 1;
a.digit[0] = 1;
@@ -429,9 +427,7 @@ get_i32 :: proc { int_get_i32, };
and maybe return max(T), .Integer_Overflow if not?
*/
int_get :: proc(a: ^Int, $T: typeid) -> (res: T, err: Error) where intrinsics.type_is_integer(T) {
- if err = clear_if_uninitialized(a); err != .None {
- return 0, err;
- }
+ if err = clear_if_uninitialized(a); err != .None { return 0, err; }
size_in_bits := int(size_of(T) * 8);
i := int((size_in_bits + _DIGIT_BITS - 1) / _DIGIT_BITS);
@@ -656,4 +652,10 @@ clamp :: proc(a: ^Int) -> (err: Error) {
a.sign = .Zero_or_Positive;
}
return .None;
-} \ No newline at end of file
+}
+
+
+_STATIC_ZERO := &Int{
+ used = 0,
+ sign = .Zero_or_Positive,
+};