summaryrefslogtreecommitdiffstats
path: root/contrib/bc/Test/testfn.b
diff options
context:
space:
mode:
authorandreas <andreas@FreeBSD.org>1998-04-29 21:53:01 +0000
committerandreas <andreas@FreeBSD.org>1998-04-29 21:53:01 +0000
commit0ec6169bea8adb8ddbf8f9ce363f6e1803f88621 (patch)
tree1529c15b522fa7bd199b5491bc88817aefc9b779 /contrib/bc/Test/testfn.b
downloadFreeBSD-src-0ec6169bea8adb8ddbf8f9ce363f6e1803f88621.zip
FreeBSD-src-0ec6169bea8adb8ddbf8f9ce363f6e1803f88621.tar.gz
Import GNU bc 1.04
PR: 4183
Diffstat (limited to 'contrib/bc/Test/testfn.b')
-rw-r--r--contrib/bc/Test/testfn.b47
1 files changed, 47 insertions, 0 deletions
diff --git a/contrib/bc/Test/testfn.b b/contrib/bc/Test/testfn.b
new file mode 100644
index 0000000..7578fc5
--- /dev/null
+++ b/contrib/bc/Test/testfn.b
@@ -0,0 +1,47 @@
+/* This function "t" tests the function "f" to see if computing at
+ two different scales has much effect on the accuracy.
+ test from f(x) to f(y) incrementing the index by d. f(i) is
+ computed at two scales, scale s and then scale t, where t>s.
+ the result from scale t is divided by 1 at scale s and the
+ results are compared. If they are different, the function is
+ said to have failed. It will then print out the value of i
+ (called index) and the two original values val1 (scale s) and
+ val2 (scale t) */
+
+define t (x,y,d,s,t) {
+ auto u, v, w, i, b, c;
+
+ if (s >= t) {
+ "Bad Scales. Try again.
+"; return;
+ }
+
+ for (i = x; i < y; i += d) {
+ scale = s;
+ u = f(i);
+ scale = t;
+ v = f(i);
+ scale = s;
+ w = v / 1;
+ b += 1;
+ if (u != w) {
+ c += 1;
+"
+Failed:
+"
+ " index = "; i;
+ " val1 = "; u;
+ " val2 = "; v;
+"
+"
+ }
+ }
+
+"
+Total tests: "; b;
+"
+Total failures: "; c;
+"
+Percent failed: "; scale = 2; c*100/b;
+
+}
OpenPOWER on IntegriCloud