big: add div by 3.

This commit is contained in:
Jeroen van Rijn
2021-08-11 20:59:51 +02:00
parent 31c94bd7f8
commit 2884fa5506
2 changed files with 119 additions and 6 deletions
+15 -6
View File
@@ -26,6 +26,7 @@ print_configation :: proc() {
SQR_KARATSUBA_CUTOFF %v
MUL_TOOM_CUTOFF %v
SQR_TOOM_CUTOFF %v
`, _DIGIT_BITS,
_MIN_DIGIT_COUNT,
_MAX_DIGIT_COUNT,
@@ -37,8 +38,6 @@ _SQR_KARATSUBA_CUTOFF,
_MUL_TOOM_CUTOFF,
_SQR_TOOM_CUTOFF,
);
fmt.println();
}
print :: proc(name: string, a: ^Int, base := i8(16)) {
@@ -54,11 +53,21 @@ print :: proc(name: string, a: ^Int, base := i8(16)) {
demo :: proc() {
err: Error;
a, b, c := &Int{}, &Int{}, &Int{};
defer destroy(a, b, c);
i: int;
destination, source, quotient, remainder, numerator, denominator := &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{};
defer destroy(destination, source, quotient, remainder, numerator, denominator);
err = set(a, 5125);
print("a", a);
err = set(numerator, 15625);
err = set(denominator, 3);
print("numerator ", numerator, 10);
print("denominator", denominator, 10);
i, err = _int_div_3(quotient, numerator);
print("quotient ", quotient, 10);
fmt.println("remainder ", i);
fmt.println("error", err);
}
main :: proc() {