chiark / gitweb /
wip js testing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 23:23:20 +0000 (00:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 23:23:20 +0000 (00:23 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/bigfloat-tests.ts [new file with mode: 0644]
templates/bigfloat.ts

diff --git a/templates/bigfloat-tests.ts b/templates/bigfloat-tests.ts
new file mode 100644 (file)
index 0000000..bc87f45
--- /dev/null
@@ -0,0 +1,15 @@
+// -*- JavaScript -*-
+// Copyright 2020 Ian Jackson
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// There is NO WARRANTY.
+
+function assert_eq(a,b) { if (a != b) throw('unequal ' + a + ' ' + b); }
+
+x = "!0000 ffff_ffff_fff0";
+y = "!0000 0000_0000_0040";
+i = Bigfloats.iter_upto(x, y, 4);
+
+assert_eq(i(), "+0000 0000_0000_0000");
+assert_eq(i(), "+0000 0000_0000_0010");
+assert_eq(i(), "+0000 0000_0000_0020");
+assert_eq(i(), "+0000x 0000_0000_0030");
index 9535f4728261c777199632648eb4090beb07347b..dc9ac26988b07cf01c21056b9080ec8ddfaf616d 100644 (file)
@@ -131,6 +131,7 @@ namespace Bigfloats {
     for (;;) {
       v.limbs[i] = Math.floor(v.limbs[i] + step);
       if (v.limbs[i] < LIMB_MODULUS) return totadj;
+      v.limbs[i] %= LIMB_MODULUS;
       i--;
       if (i < 0) {
        if (v.sign < 0) { v.sign = +1; return totadj; }