mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
bigint: Add prototypes for immediate add+sub.
This commit is contained in:
@@ -21,7 +21,7 @@ import "core:intrinsics"
|
|||||||
/*
|
/*
|
||||||
High-level addition. Handles sign.
|
High-level addition. Handles sign.
|
||||||
*/
|
*/
|
||||||
add :: proc(dest, a, b: ^Int) -> (err: Error) {
|
add_two_ints :: proc(dest, a, b: ^Int) -> (err: Error) {
|
||||||
dest := dest; x := a; y := b;
|
dest := dest; x := a; y := b;
|
||||||
_panic_if_uninitialized(a); _panic_if_uninitialized(b); _panic_if_uninitialized(dest);
|
_panic_if_uninitialized(a); _panic_if_uninitialized(b); _panic_if_uninitialized(dest);
|
||||||
|
|
||||||
@@ -46,10 +46,23 @@ add :: proc(dest, a, b: ^Int) -> (err: Error) {
|
|||||||
return _sub(dest, x, y);
|
return _sub(dest, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Adds the unsigned `DIGIT` immediate to an `Int`,
|
||||||
|
such that the `DIGIT` doesn't have to be turned into an `Int` first.
|
||||||
|
|
||||||
|
dest = a + digit;
|
||||||
|
*/
|
||||||
|
add_digit :: proc(dest, a: ^int, digit: DIGIT) -> (err: Error) {
|
||||||
|
|
||||||
|
return .Unimplemented;
|
||||||
|
}
|
||||||
|
|
||||||
|
add :: proc{add_two_ints, add_digit};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
High-level subtraction, dest = number - decrease. Handles signs.
|
High-level subtraction, dest = number - decrease. Handles signs.
|
||||||
*/
|
*/
|
||||||
sub :: proc(dest, number, decrease: ^Int) -> (err: Error) {
|
sub_two_ints :: proc(dest, number, decrease: ^Int) -> (err: Error) {
|
||||||
dest := dest; x := number; y := decrease;
|
dest := dest; x := number; y := decrease;
|
||||||
_panic_if_uninitialized(number); _panic_if_uninitialized(decrease); _panic_if_uninitialized(dest);
|
_panic_if_uninitialized(number); _panic_if_uninitialized(decrease); _panic_if_uninitialized(dest);
|
||||||
|
|
||||||
@@ -83,6 +96,19 @@ sub :: proc(dest, number, decrease: ^Int) -> (err: Error) {
|
|||||||
return _sub(dest, x, y);
|
return _sub(dest, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Adds the unsigned `DIGIT` immediate to an `Int`,
|
||||||
|
such that the `DIGIT` doesn't have to be turned into an `Int` first.
|
||||||
|
|
||||||
|
dest = number - decrease;
|
||||||
|
*/
|
||||||
|
sub_digit :: proc(dest, number: ^int, decrease: DIGIT) -> (err: Error) {
|
||||||
|
|
||||||
|
return .Unimplemented;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub :: proc{sub_two_ints, sub_digit};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==========================
|
==========================
|
||||||
Low-level routines
|
Low-level routines
|
||||||
|
|||||||
Reference in New Issue
Block a user