From 519765407150892e2e57929d4c00fc5ea7840529 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 14 Oct 2016 07:36:53 +0200 Subject: Remove mention of bigint testing python script --- bigint.cpp | 1 - biginttest.py | 39 --------------------------------------- 2 files changed, 40 deletions(-) delete mode 100755 biginttest.py diff --git a/bigint.cpp b/bigint.cpp index e57752f..0d2a72b 100644 --- a/bigint.cpp +++ b/bigint.cpp @@ -347,7 +347,6 @@ pair Bigint::divmod(const Bigint &div) const { pair p=divmod(*this,div,bitcdiff/29+10); //ignores all signs /* To let the result come out correctly, we apply case analysis to the signs of the arguments. * As a guiding example, these two cases can be examined. - * The code was tested with many large random numbers (also negative), using a Python script. * (1) 4 = 1* 3 + 1 6 = 2* 3 + 0 * (2) 4 = -1*-3 + 1 6 = -2*-3 + 0 * (3) -4 = -2* 3 + 2 -6 = -2* 3 + 0 diff --git a/biginttest.py b/biginttest.py deleted file mode 100755 index 71c5417..0000000 --- a/biginttest.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 -import sys, random, subprocess - -ntimes=10000 -maxn=1e100 - -def check(desc,x,y): - if x==y: return - print("{}: {} != {}".format(desc,x,y)) - assert False - -def gendata(): - for _ in range(ntimes): - yield random.randint(-maxn,maxn), random.randint(-maxn,maxn) - -def proctest(): - proc=subprocess.Popen(["./main"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=sys.stderr) - - for (a,b) in gendata(): - proc.stdin.write("div {} {}\n".format(a,b).encode("ascii")) - proc.stdin.write("mod {} {}\n".format(a,b).encode("ascii")) - proc.stdin.flush() - - q=int(proc.stdout.readline()) - r=int(proc.stdout.readline()) - if r<0 or r>=abs(b) or a!=q*b+r: - print("Error: {} divmod {}".format(a,b)) - print("Diff: {}".format(a-q*b-r)) - sys.exit(1) - - proc.kill() - -def justprint(): - for (a,b) in gendata(): - print("div {} {}".format(a,b)) - print("mod {} {}".format(a,b)) - -#justprint() -proctest() -- cgit v1.2.3-70-g09d2