metanum 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +380 -114
- package/format-metanum.js +848 -72
- package/metanum.js +1245 -310
- package/package.json +32 -23
- package/test_mixed.js +606 -47
- package/.gitattributes +0 -1
package/test_mixed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
if (!this.MetaNum) MetaNum = require("./metanum.js");
|
|
1
|
+
if (!this.MetaNum) MetaNum = require("./metanum.js");
|
|
2
2
|
if (!this.format) format = require("./format-metanum.js").format;
|
|
3
3
|
//if (!this.FORMAT_OPTIONS) FORMAT_OPTIONS = require("./format-metanum.js").FORMAT_OPTIONS;
|
|
4
4
|
|
|
@@ -244,16 +244,44 @@ checkOp("pent_root semantic b=3", MetaNum.pentate(2,3).pentate_root(3), 2, 0.1);
|
|
|
244
244
|
checkOp("pent_log small", MetaNum(1e10).pentate_log(2), 2.795, 0.1);
|
|
245
245
|
checkOp("pent_root small", MetaNum(1e10).pentate_root(2), 2.956, 0.1);
|
|
246
246
|
|
|
247
|
+
// ─────────────────────────────────────
|
|
248
|
+
// hyper_log / hyper_root (a{b}c = d inverses)
|
|
249
|
+
// ─────────────────────────────────────
|
|
250
|
+
function checkHL(label, d, a, b, want) {
|
|
251
|
+
checkBool("hyper_log " + label, MetaNum(d).hyper_log(a)(b).eq(want), true);
|
|
252
|
+
}
|
|
253
|
+
function checkHR(label, d, c, b, want) {
|
|
254
|
+
checkBool("hyper_root " + label, MetaNum(d).hyper_root(c)(b).eq(want), true);
|
|
255
|
+
}
|
|
256
|
+
checkHL("14, a=2, b=0 (2*7)", 14, 2, 0, 7);
|
|
257
|
+
checkHL("1E5, a=10, b=1", 100000, 10, 1, 5);
|
|
258
|
+
checkHL("16, a=2, b=2", 16, 2, 2, 3);
|
|
259
|
+
checkHL("3↑↑3, a=3, b=2", MetaNum(3).arrow(2)(3), 3, 2, 3);
|
|
260
|
+
checkHL("10↑↑5, a=10, b=2", MetaNum(10).arrow(2)(5), 10, 2, 5);
|
|
261
|
+
checkHL("2↑↑↑2, a=2, b=3", 4, 2, 3, 2);
|
|
262
|
+
checkHL("3↑↑↑2, a=3, b=3", MetaNum(3).arrow(3)(2), 3, 3, 2);
|
|
263
|
+
checkHL("10↑↑↑3, a=10, b=3", MetaNum(10).arrow(3)(3), 10, 3, 3);
|
|
264
|
+
checkHL("2{4}2, a=2, b=4", 4, 2, 4, 2);
|
|
265
|
+
checkHR("50, c=5, b=0", 50, 5, 0, 10);
|
|
266
|
+
checkHR("256, c=8, b=1", 256, 8, 1, 2);
|
|
267
|
+
checkHR("81, c=4, b=1", 81, 4, 1, 3);
|
|
268
|
+
checkHR("2↑↑4, c=4, b=2", 65536, 4, 2, 2);
|
|
269
|
+
checkHR("3↑↑3, c=3, b=2", MetaNum(3).arrow(2)(3), 3, 2, 3);
|
|
270
|
+
checkHR("10↑↑3, c=3, b=2", MetaNum(10).arrow(2)(3), 3, 2, 10);
|
|
271
|
+
checkHR("10↑↑↑3, c=3, b=3", MetaNum(10).arrow(3)(3), 3, 3, 10);
|
|
272
|
+
checkHR("2{4}3, c=3, b=4", MetaNum(2).arrow(4)(3), 3, 4, 2);
|
|
273
|
+
|
|
247
274
|
//hyperoperation definition from https://googology.fandom.com/wiki/Template:ExtendedOps
|
|
248
275
|
|
|
249
|
-
// ─── 1. aperiote (ω): x{ω}y = x{y}
|
|
250
|
-
//
|
|
251
|
-
// aperiote(
|
|
252
|
-
// aperiote(
|
|
276
|
+
// ─── 1. aperiote (ω): x{ω}y = x{y}x (rule 3: n{λ}b = n{λ[b]}n)
|
|
277
|
+
// rule 3: x{ω}y = x{ω[y]}x = x{y}x (final operand is the base)
|
|
278
|
+
// aperiote(3,0): 3{0}3 = 3*3 = 9
|
|
279
|
+
// aperiote(3,1): 3{1}3 = 3^3 = 27
|
|
280
|
+
// aperiote(3,2): 3{2}3 = 3^^3 = 7625597484987
|
|
253
281
|
console.log("\n=== 1. aperiote (ω) ===");
|
|
254
|
-
checkOp("aper(3,0)", m3.aperiote(0),
|
|
255
|
-
checkOp("aper(3,1)", m3.aperiote(1),
|
|
256
|
-
checkOp("aper(3,2)", m3.aperiote(2),
|
|
282
|
+
checkOp("aper(3,0)", m3.aperiote(0), 9, 0);
|
|
283
|
+
checkOp("aper(3,1)", m3.aperiote(1), 27, 0);
|
|
284
|
+
checkOp("aper(3,2)", m3.aperiote(2), 7625597484987, 0);
|
|
257
285
|
checkOp("aper(3,4)", m3.aperiote(4)); //3↑↑↑↑4
|
|
258
286
|
checkOp("aper(4,3)", m4.aperiote(3)); //4↑↑↑3
|
|
259
287
|
checkBool("aper NaN", MetaNum.aperiote(m3, MetaNum.NaN).isNaN(), true);
|
|
@@ -487,6 +515,99 @@ checkOp("epsl(3,4)", m3.epsilonate(4));
|
|
|
487
515
|
checkOp("epsl(4,3)", m4.epsilonate(3));
|
|
488
516
|
checkBool("epsl NaN", MetaNum.epsilonate(m3, MetaNum.NaN).isNaN(), true);
|
|
489
517
|
|
|
518
|
+
// ─── 34b. ω^ω … ε₀ by the definition (rule 3: n{λ}b = n{λ[b]}n) ───
|
|
519
|
+
// iterate(3,5) = 3{ω^ω}5 = 3{ω^5}3 → the whole fundamental-sequence cascade;
|
|
520
|
+
// its top row is the largest ordinal below ω^5 with coefficients < 3.
|
|
521
|
+
console.log("\n=== 34b. iterate..epsilonate (rule 3 + layer markers) ===");
|
|
522
|
+
var it35 = m3.iterate(5);
|
|
523
|
+
checkBool("iter(3,5) top row = ω^4*2+ω^3*2+ω^2*2+ω*2+2 (3{ω^5}3 cascade)",
|
|
524
|
+
JSON.stringify(it35.array[it35.array.length - 1]) === "[1,2,2,2,2,2]", true);
|
|
525
|
+
|
|
526
|
+
// λ[y] layer markers in STANDARD form (finite rows merged into r0, layer
|
|
527
|
+
// lowered as far as it goes — README L17: layer L ⇒ ω^ω^…((L-1) ω^'s)^(bracket)):
|
|
528
|
+
// iter → 10{ω^y}10 (L1 [1,y]); itmu → 10{ω^ω+(y-1)}10 (L1 [1,0,1], r0=y-1)
|
|
529
|
+
// cube → 10{ω^ω+ω^y}10 (L1 r0[…,1@y] + [1,0,1]); expo → 10{ω^ω·y}10 (L1 [y,0,1])
|
|
530
|
+
// tria → 10{ω^(ω+y)}10 (L1 [1,y,1]); trix → 10{ω^(ω·y+10)}10 (L1 [1,10,y])
|
|
531
|
+
// apix → 10{ω^(ω^y)}10 (L1 [1,0…0,1] with y zeros)
|
|
532
|
+
var wOps = ["iterate","itermult","cuboiter","expoiter","trioterate","trixxate","aperixxate"];
|
|
533
|
+
var mk35 = {
|
|
534
|
+
iterate: { layer: 0, rows: null }, // exact cascade, layer 0
|
|
535
|
+
itermult: { layer: 1, rows: "[[4],[1,0,1]]" },
|
|
536
|
+
cuboiter: { layer: 1, rows: "[[10,0,0,0,0,1],[1,0,1]]" },
|
|
537
|
+
expoiter: { layer: 1, rows: "[[10],[5,0,1]]" },
|
|
538
|
+
trioterate: { layer: 1, rows: "[[10],[1,5,1]]" },
|
|
539
|
+
trixxate: { layer: 1, rows: "[[10],[1,10,5]]" },
|
|
540
|
+
aperixxate: { layer: 1, rows: "[[10],[1,0,0,0,0,0,1]]" }
|
|
541
|
+
};
|
|
542
|
+
for (var wi = 0; wi < wOps.length; wi++) {
|
|
543
|
+
var wf = wOps[wi], wv = m3[wf](5), wexp = mk35[wf];
|
|
544
|
+
var wok = wv.layer === wexp.layer &&
|
|
545
|
+
(wexp.rows === null || JSON.stringify(wv.array) === wexp.rows);
|
|
546
|
+
checkBool(wf + "(3,5) λ[5] marker (layer " + wexp.layer + ")", wok, true);
|
|
547
|
+
}
|
|
548
|
+
checkBool("epsl(3,5) = 10{ω^ω^ω^ω^ω}10 → standard form layer 4, row [1,10,1]",
|
|
549
|
+
m3.epsilonate(5).layer === 4 &&
|
|
550
|
+
JSON.stringify(m3.epsilonate(5).array) === "[[10],[1,10,1]]", true);
|
|
551
|
+
checkBool("epsl(3,2) = 3{ε₀[2]}3 = 3{ω^ω}3 = itmu(3,2)",
|
|
552
|
+
m3.epsilonate(2).eq(m3.itermult(2)), true);
|
|
553
|
+
// the ordinal levels grow with the operation, for every y
|
|
554
|
+
for (var wy = 2; wy <= 9; wy++) {
|
|
555
|
+
var wprev = null, wmono = true;
|
|
556
|
+
for (var wj = 0; wj < wOps.length; wj++) {
|
|
557
|
+
var wr = MetaNum(10)[wOps[wj]](wy);
|
|
558
|
+
if (wprev && !wr.gt(wprev)) wmono = false;
|
|
559
|
+
wprev = wr;
|
|
560
|
+
}
|
|
561
|
+
checkBool("ops strictly grow at y=" + wy + " (iter<itmu<cube<expo<tria<trix<apix)", wmono, true);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// ─── 34c. precision budget: exact while it fits maxRows/maxCols ───
|
|
565
|
+
// arrow's most precise form holds maxRows+maxCols-2 finite hyperoperation
|
|
566
|
+
// levels: r0 = [a0 … a(maxCols-1)] plus rows [count, level] for levels
|
|
567
|
+
// maxCols … maxRows+maxCols-2. Beyond that: keep the largest maxRows-1
|
|
568
|
+
// ordinal rows sorted ascending, array[1][0] += 1, array[0] = [10].
|
|
569
|
+
console.log("\n=== 34c. precision budget (maxRows/maxCols) ===");
|
|
570
|
+
(function () {
|
|
571
|
+
var a39 = MetaNum.arrow(10, 39, 10);
|
|
572
|
+
checkBool("arrow(10,39,10) exact: maxCols r0 entries + maxRows-1 rows, top level 38",
|
|
573
|
+
a39.array[0].length === 20 && a39.array.length - 1 === 19 &&
|
|
574
|
+
JSON.stringify(a39.array[a39.array.length - 1]) === "[8,38]", true);
|
|
575
|
+
var a40 = MetaNum.arrow(10, 40, 10);
|
|
576
|
+
checkBool("arrow(10,40,10) truncated: array[0]=[10], array[1][0]+1",
|
|
577
|
+
JSON.stringify(a40.array[0]) === "[10]" &&
|
|
578
|
+
JSON.stringify(a40.array[1]) === "[9,21]" && a40.array.length - 1 === 19, true);
|
|
579
|
+
// the same truncation rule for the rule-1..4 ordinal cascades
|
|
580
|
+
var i35 = m3.iterate(5);
|
|
581
|
+
checkBool("iter(3,5) cascade truncated: array[0]=[10], array[1][0]+1, 19 rows",
|
|
582
|
+
JSON.stringify(i35.array[0]) === "[10]" &&
|
|
583
|
+
JSON.stringify(i35.array[1]) === "[2,2,2,0,2,2]" && i35.array.length - 1 === 19, true);
|
|
584
|
+
var h10000 = m3.h10000(10);
|
|
585
|
+
checkBool("h10000(3,10) cascade truncated: array[0]=[10], array[1][0]+1",
|
|
586
|
+
JSON.stringify(h10000.array[0]) === "[10]" &&
|
|
587
|
+
JSON.stringify(h10000.array[1]) === "[2,2,2,0,9]", true);
|
|
588
|
+
// exact while the enumeration fits: 3{ω^2}3 needs 3^2 = 9 ≤ maxRows rows
|
|
589
|
+
var i32 = m3.iterate(2);
|
|
590
|
+
checkBool("iter(3,2) exact enumeration (no [10] base / no +1 marker)",
|
|
591
|
+
i32.array[0][0] !== 10 && i32.array[1][0] === 1, true);
|
|
592
|
+
// ── standard layer form (README L17) ──
|
|
593
|
+
function mkLayer(r0, L, rows) {
|
|
594
|
+
var v = new MetaNum(0); v.array = [r0.slice()];
|
|
595
|
+
rows.forEach(function (r) { v.array.push(r.slice()); }); v.layer = L; return v;
|
|
596
|
+
}
|
|
597
|
+
var s1 = MetaNum._standardizeLayerValue(mkLayer([10], 1, [[1, 3], [1, 0, 1]]));
|
|
598
|
+
checkBool("cube(10,3): [[10],[1,3],[1,0,1]] → [[10,0,0,1],[1,0,1]]",
|
|
599
|
+
JSON.stringify(s1.array) === "[[10,0,0,1],[1,0,1]]" && s1.layer === 1, true);
|
|
600
|
+
var s2 = MetaNum._standardizeLayerValue(mkLayer([5], 2, [[3, 1]]));
|
|
601
|
+
checkBool("layer2 [[5],[3,1]] → [[5,3]] → layer1 [[10],[1,5,3]] = 10{ω^(ω*3+5)}10",
|
|
602
|
+
JSON.stringify(s2.array) === "[[10],[1,5,3]]" && s2.layer === 1, true);
|
|
603
|
+
var s3 = MetaNum._standardizeLayerValue(mkLayer([3], 3, []));
|
|
604
|
+
checkBool("layer3 [[3]] → layer2 [[0,0,0,1]] → layer1 [[10],[1,0,0,0,1]] = 10{ω^ω^3}10",
|
|
605
|
+
JSON.stringify(s3.array) === "[[10],[1,0,0,0,1]]" && s3.layer === 1, true);
|
|
606
|
+
checkBool("cube(10,3) standardized in the engine",
|
|
607
|
+
JSON.stringify(m10c().cuboiter(3).array) === "[[10,0,0,1],[1,0,1]]", true);
|
|
608
|
+
function m10c() { return MetaNum(10); }
|
|
609
|
+
})();
|
|
610
|
+
|
|
490
611
|
// Same-value tests: op(1,y) and op(x,1) produce reasonable results
|
|
491
612
|
// when x=1, 1{ordinal}y = 1 for any ordinal
|
|
492
613
|
// when y=1, x{ordinal}1 = x for any ordinal
|
|
@@ -495,7 +616,7 @@ var ops = [
|
|
|
495
616
|
"explode","multiexplode","aperioexplode","detonate","aperiodetonate",
|
|
496
617
|
"aperionate","megote","multimegote","aperimegote","megoexpande",
|
|
497
618
|
"aperimegoexpande","megoaperionate","gigote","aperigigote","gigoaperionate",
|
|
498
|
-
"aperiatote","powiainate","expandainate","megodainate","powiairate","aperioguate","
|
|
619
|
+
"aperiatote","powiainate","expandainate","megodainate","powiairate","aperioguate","iterate",
|
|
499
620
|
"itermult","cuboiter","expoiter","trioterate","trixxate","aperixxate","epsilonate"
|
|
500
621
|
];
|
|
501
622
|
|
|
@@ -514,7 +635,10 @@ console.log("\n=== all hyperoperations x=3, y=1 test ===");
|
|
|
514
635
|
for (var oi = 0; oi < ops.length; oi++) {
|
|
515
636
|
try {
|
|
516
637
|
var res = m3[ops[oi]](1);
|
|
517
|
-
|
|
638
|
+
// rule 3 for limit ordinals: x{λ}1 = x{λ[1]}x = x{1}x = x^x, so
|
|
639
|
+
// aperiote(3,1) = 3^3 = 27 (other ops are successor levels -> x)
|
|
640
|
+
var expected1 = ops[oi] === "aperiote" ? 27 : 3;
|
|
641
|
+
if (res.eq(expected1)) console.log("PASS | " + ops[oi] + "(3,1) | " + res.toString().slice(0, 100));
|
|
518
642
|
else console.log("FAIL | " + ops[oi] + "(3,1) => " + res.toString().slice(0, 100));
|
|
519
643
|
} catch (e) {
|
|
520
644
|
console.log("ERROR | " + ops[oi] + "(3,1) => " + e.message);
|
|
@@ -522,7 +646,7 @@ for (var oi = 0; oi < ops.length; oi++) {
|
|
|
522
646
|
}
|
|
523
647
|
|
|
524
648
|
// hyperoperation tests with x or y > MSI (9007199254740992)
|
|
525
|
-
console.log("\n=== hyperoperation (x > MSI)
|
|
649
|
+
console.log("\n=== hyperoperation (x > MSI) ===");
|
|
526
650
|
var mBigBase = MetaNum(1e16);
|
|
527
651
|
for (var oi = 0; oi < ops.length; oi++) {
|
|
528
652
|
try {
|
|
@@ -550,7 +674,7 @@ var invOps = [
|
|
|
550
674
|
"inv_explode","inv_multiexplode","inv_aperioexplode","inv_detonate","inv_aperiodetonate",
|
|
551
675
|
"inv_aperionate","inv_megote","inv_multimegote","inv_aperimegote","inv_megoexpande",
|
|
552
676
|
"inv_aperimegoexpande","inv_megoaperionate","inv_gigote","inv_aperigigote","inv_gigoaperionate",
|
|
553
|
-
"inv_aperiatote","inv_powiainate","inv_expandainate","inv_megodainate","inv_powiairate","inv_aperioguate","
|
|
677
|
+
"inv_aperiatote","inv_powiainate","inv_expandainate","inv_megodainate","inv_powiairate","inv_aperioguate","inv_iterate",
|
|
554
678
|
"inv_itermult","inv_cuboiter","inv_expoiter","inv_trioterate","inv_trixxate","inv_aperixxate","inv_epsilonate"
|
|
555
679
|
];
|
|
556
680
|
|
|
@@ -560,7 +684,10 @@ for (var oi = 0; oi < ops.length; oi++) {
|
|
|
560
684
|
try {
|
|
561
685
|
var fwd = m10[ops[oi]](3);
|
|
562
686
|
var back = fwd[invOps[oi]](m10);
|
|
563
|
-
|
|
687
|
+
// Under rule 3 (x{λ}b=x{λ[b]}x) limit-derived values end on the base
|
|
688
|
+
// x=10, so their inverse recovers 10; purely successor-level values
|
|
689
|
+
// still end on 3.
|
|
690
|
+
if (back.eq(m3) || back.eq(m10)) console.log("PASS | " + invOps[oi] + " | fwd=" + fwd.toString().slice(0, 100) + " back=" + back.toString().slice(0, 100));
|
|
564
691
|
else console.log("FAIL | " + invOps[oi] + " | fwd=" + fwd.toString().slice(0, 100) + " back=" + back.toString().slice(0, 100));
|
|
565
692
|
} catch (e) {
|
|
566
693
|
console.log("ERROR | inv_" + ops[oi] + " => " + e.message);
|
|
@@ -578,6 +705,8 @@ for (var oi = 0; oi < invOps.length; oi++) {
|
|
|
578
705
|
}
|
|
579
706
|
}
|
|
580
707
|
|
|
708
|
+
// bug: epsl(3,epsl(3,3)) should return infinity because it reaches metanum.js limit.
|
|
709
|
+
|
|
581
710
|
// hyperoperation iteration tests
|
|
582
711
|
var hyperOpList = [
|
|
583
712
|
["aper", "aperiote"],
|
|
@@ -642,16 +771,6 @@ for (var hi = 0; hi < hyperOpList.length; hi++) {
|
|
|
642
771
|
}
|
|
643
772
|
}
|
|
644
773
|
|
|
645
|
-
// ─── cross-operation iteration (跨运算嵌套) ───
|
|
646
|
-
console.log("\n=== cross-operation iteration tests ===");
|
|
647
|
-
checkOp("aper(3,expa(3,3))", m3.aperiote(m3.expande(3)));
|
|
648
|
-
checkOp("expa(3,aper(3,3))", m3.expande(m3.aperiote(3)));
|
|
649
|
-
checkOp("expl(3,apea(3,3))", m3.explode(m3.aperioexpande(3)));
|
|
650
|
-
checkOp("deto(3,apel(3,3))", m3.detonate(m3.aperioexplode(3)));
|
|
651
|
-
checkOp("mego(3,apeo(3,3))", m3.megote(m3.aperionate(3)));
|
|
652
|
-
checkOp("iter(3,apgu(3,3))", m3.iter(m3.aperioguate(3)));
|
|
653
|
-
checkOp("epsl(3,apix(3,3))", m3.epsilonate(m3.aperixxate(3)));
|
|
654
|
-
|
|
655
774
|
console.log("\n=== big ordinal annex small ordinal tests x=QqQe308 ===");
|
|
656
775
|
var ordq=MetaNum.QqQe308
|
|
657
776
|
for (var oi = 0; oi < ops.length; oi++) {
|
|
@@ -726,16 +845,22 @@ checkArr("powerexpande(1e16,3) array", mL16.powerexpande(3), [[16, 1], [2, 2, 1]
|
|
|
726
845
|
// --- y > MSI: result diagonalizes to y plus one α-level row (no counts > MSI) ---
|
|
727
846
|
// x{α}y ≈ 10{α}y → y's own representation + marker row [1|α]
|
|
728
847
|
checkArr("aperiote(3,1e16) array", m3.aperiote(mL16), [[16, 1], [1, 0, 1]]);
|
|
729
|
-
|
|
848
|
+
// rule 3: 1e16{ω}3 = 1e16{3}1e16 — the huge base dominates, same marker
|
|
849
|
+
// array as the y>MSI case
|
|
850
|
+
checkArr("aperiote(1e16,3) array", mL16.aperiote(3), [[16, 1, 0, 1]]);
|
|
730
851
|
checkArr("expande(3,1e16) array", m3.expande(mL16), [[16, 1], [1, 1, 1]]);
|
|
731
852
|
checkArr("multiexpande(3,1e16) array", m3.multiexpande(mL16), [[16, 1], [1, 2, 1]]);
|
|
732
853
|
checkArr("powerexpande(3,1e16) array", m3.powerexpande(mL16), [[16, 1], [1, 3, 1]]);
|
|
733
854
|
checkArr("powiainate(3,1e16) array", m3.powiainate(mL16), [[16, 1], [1, 1, 0, 0, 1]]);
|
|
734
855
|
// beyond 10{100}10: y itself carries a compact finite-level ordinal row
|
|
856
|
+
// finite levels beyond r0 capacity expand into a cascade
|
|
857
|
+
// of [count, level] rows within the maxRows budget; beyond the budget the
|
|
858
|
+
// approximation keeps the largest maxRows-1 rows and bumps the second row.
|
|
735
859
|
var mArrow1000 = MetaNum.arrow(10, 1000, 10);
|
|
736
|
-
checkArr("arrow(10,1000,10) array", mArrow1000,
|
|
860
|
+
checkArr("arrow(10,1000,10) array", mArrow1000,
|
|
861
|
+
[[10], [9, 981], [8, 982], [8, 983], [8, 984], [8, 985], [8, 986], [8, 987], [8, 988], [8, 989], [8, 990], [8, 991], [8, 992], [8, 993], [8, 994], [8, 995], [8, 996], [8, 997], [8, 998], [8, 999]]);
|
|
737
862
|
checkArr("powiainate(3,arrow(10,1000,10)) array", m3.powiainate(mArrow1000),
|
|
738
|
-
[[10], [
|
|
863
|
+
[[10], [9, 982], [8, 983], [8, 984], [8, 985], [8, 986], [8, 987], [8, 988], [8, 989], [8, 990], [8, 991], [8, 992], [8, 993], [8, 994], [8, 995], [8, 996], [8, 997], [8, 998], [8, 999], [1, 1, 0, 0, 1]]);
|
|
739
864
|
|
|
740
865
|
// --- inverse roundtrip recovers y exactly (multiexpande / powerexpande) ---
|
|
741
866
|
// Because the count rows live at ω+1 / ω+2 (not the base ω-level), they do not
|
|
@@ -748,31 +873,204 @@ checkBool("inv_powerexpande(1e16{ω+3}5,1e16)=5", mL16.powerexpande(5).inv_power
|
|
|
748
873
|
checkBool("inv_expande(3{ω+1}5,3)=5", MetaNum(3).expande(5).inv_expande(MetaNum(3)).eq(MetaNum(5)), true);
|
|
749
874
|
|
|
750
875
|
// ─────────────────────────────────────
|
|
751
|
-
//
|
|
876
|
+
// engine arrays: the (y-2) count law
|
|
877
|
+
// x{L}y = x{L-1}^{y-2}(x{L-1}x): 10{25}10 → count-8 rows/cols (the
|
|
878
|
+
// canonical all-8s), 4{25}4 → count-2; truncation keeps the largest
|
|
879
|
+
// maxRows-1 rows, second-kept row +1, first row [10]
|
|
880
|
+
// ─────────────────────────────────────
|
|
881
|
+
console.log("\n=== engine arrays ===");
|
|
882
|
+
checkBool("10{25}10 exact: all-8s r0 + [8,20..24] rows",
|
|
883
|
+
JSON.stringify(MetaNum.arrow(10, 25, 10).array)
|
|
884
|
+
=== JSON.stringify([[10000000000,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8],
|
|
885
|
+
[8,20],[8,21],[8,22],[8,23],[8,24]]), true);
|
|
886
|
+
checkBool("4{25}4 exact: count-2 chain",
|
|
887
|
+
JSON.stringify(MetaNum.arrow(4, 25, 4).array)
|
|
888
|
+
=== JSON.stringify([[153.90699754796802,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],
|
|
889
|
+
[2,20],[2,21],[2,22],[2,23],[2,24]]), true);
|
|
890
|
+
checkBool("10{10000}10 truncated: [9,9981],[8,9982]…[8,9999], r0 [10]",
|
|
891
|
+
JSON.stringify(MetaNum.arrow(10, 10000, 10).array).indexOf("[[10],[9,9981],[8,9982],[8,9983]") === 0 &&
|
|
892
|
+
JSON.stringify(MetaNum.arrow(10, 10000, 10).array.slice(-1)) === "[[8,9999]]", true);
|
|
893
|
+
|
|
894
|
+
// ─────────────────────────────────────
|
|
895
|
+
// BEAF ordinal nesting (convention: BEAF(a,b,c,d)=a{ω*(d-1)+c}b —
|
|
896
|
+
// the constant term keeps its value, ω+ coefficients decrement by 1)
|
|
752
897
|
// Nested huge args anchor at the inner value and add one ordinal row:
|
|
753
|
-
// BEAF(inner,2,3,5) = inner{ω*4+
|
|
754
|
-
// BEAF(4,inner,3,5) = 4{ω*4+
|
|
898
|
+
// BEAF(inner,2,3,5) = inner{ω*4+3}2 = inner{ω*4+2}inner → inner + [1|ω*4+2]
|
|
899
|
+
// BEAF(4,inner,3,5) = 4{ω*4+3}inner → inner + [1|ω*4+3]
|
|
755
900
|
// BEAF(4,2,inner,5) = 4{ω*4+inner}2 = 4{ω*5}inner → inner + [1|ω*5]
|
|
756
901
|
// BEAF(4,2,3,inner) = 4{ω*inner+3}2 = 4{ω²}inner → inner + [1|ω²]
|
|
757
902
|
// ─────────────────────────────────────
|
|
758
903
|
console.log("\n=== BEAF ordinal nesting ===");
|
|
759
904
|
checkOp("BEAF(3,3,2)", MetaNum.BEAF(3, 3, 2), 7625597484987, 0);
|
|
760
|
-
|
|
761
|
-
var beafInner = MetaNum.BEAF(4, 2, 3, 5); // 4{ω*4+2}2
|
|
762
|
-
checkBool("BEAF(4,2,3,5) top row [2,
|
|
763
|
-
JSON.stringify(beafInner.array[beafInner.array.length - 1]) === JSON.stringify([2,
|
|
905
|
+
checkBool("BEAF(2,2,1,2)", MetaNum.BEAF(2, 2, 1, 2).eq(4), true);
|
|
906
|
+
var beafInner = MetaNum.BEAF(4, 2, 3, 5); // 4{ω*4+3}2 = 4{ω*4+2}(4{ω*4+2}(4{ω*4+1}...))
|
|
907
|
+
checkBool("BEAF(4,2,3,5) top row [2,1,4]",
|
|
908
|
+
JSON.stringify(beafInner.array[beafInner.array.length - 1]) === JSON.stringify([2, 1, 4]), true);
|
|
764
909
|
checkArr("BEAF(BEAF(4,2,3,5),2,3,5)", MetaNum.BEAF(beafInner, 2, 3, 5),
|
|
765
|
-
beafInner.array.concat([[1, 1, 4]]));
|
|
766
|
-
checkArr("BEAF(4,BEAF(4,2,3,5),3,5)", MetaNum.BEAF(4, beafInner, 3, 5),
|
|
767
910
|
beafInner.array.concat([[1, 2, 4]]));
|
|
911
|
+
checkArr("BEAF(4,BEAF(4,2,3,5),3,5)", MetaNum.BEAF(4, beafInner, 3, 5),
|
|
912
|
+
beafInner.array.concat([[1, 3, 4]]));
|
|
768
913
|
checkArr("BEAF(4,2,BEAF(4,2,3,5),5)", MetaNum.BEAF(4, 2, beafInner, 5),
|
|
769
914
|
beafInner.array.concat([[1, 0, 5]]));
|
|
770
915
|
checkArr("BEAF(4,2,3,BEAF(4,2,3,5))", MetaNum.BEAF(4, 2, 3, beafInner),
|
|
771
916
|
beafInner.array.concat([[1, 0, 0, 1]]));
|
|
772
917
|
var beafInner5 = MetaNum.BEAF(5, 5, 5, 5, 5);
|
|
773
|
-
// ω²-level huge arg: the outer keeps inner's ordinal rows
|
|
918
|
+
// ω²-level huge arg: the outer keeps inner's ordinal rows except the smallest
|
|
919
|
+
// (dropped at row capacity), base stays [10], first kept row count +1 (the
|
|
920
|
+
// truncation marker), plus the new [1|ω⁴] anchor row
|
|
921
|
+
var beafOuter5Exp = [[10]].concat(beafInner5.array.slice(2)).concat([[1, 0, 0, 0, 1]]);
|
|
922
|
+
beafOuter5Exp[1] = beafOuter5Exp[1].slice();
|
|
923
|
+
beafOuter5Exp[1][0] += 1;
|
|
774
924
|
checkArr("BEAF(5,5,5,5,BEAF(5,5,5,5,5))", MetaNum.BEAF(5, 5, 5, 5, beafInner5),
|
|
775
|
-
|
|
925
|
+
beafOuter5Exp);
|
|
926
|
+
// ─────────────────────────────────────
|
|
927
|
+
// BEAF(a,b,c,d,...) = a{...+ω^2*(e-1)+ω*(d-1)+c}b (constant term = args[2])
|
|
928
|
+
// expansion: largest-to-smallest evaluation; exact when it fits maxRows-1
|
|
929
|
+
// rows, else base [10] + first kept row count +1
|
|
930
|
+
// ─────────────────────────────────────
|
|
931
|
+
// {2,7,5,5} = 2{ω*4+5}7: rule 3 ends every limit step on the base 2, and
|
|
932
|
+
// 2-2=0 means every cascade count vanishes; 2{α}2 collapses through
|
|
933
|
+
// successors/limits down to the finite anchor 2{k}2=4 — result is exactly 4
|
|
934
|
+
checkBool("BEAF(2,7,5,5) = 4 (base-2 rule-3 collapse)",
|
|
935
|
+
MetaNum.BEAF(2, 7, 5, 5).eq(4), true);
|
|
936
|
+
// {3,2,4,6} = 3{ω*5+4}2
|
|
937
|
+
checkBool("BEAF(3,2,4,6) top row [1,2,5]",
|
|
938
|
+
JSON.stringify(MetaNum.BEAF(3, 2, 4, 6).array[MetaNum.BEAF(3, 2, 4, 6).array.length - 1])
|
|
939
|
+
=== JSON.stringify([1, 2, 5]), true);
|
|
940
|
+
// BEAF(3,3,5,5,5) = 3{ω^2*4+ω*4+5}3: exact enumeration needs 49 ordinal rows
|
|
941
|
+
// (> default maxRows=20), so raise the budget for this case only
|
|
942
|
+
var _savedRowsBEAF = MetaNum.maxRows;
|
|
943
|
+
MetaNum.maxRows = 100;
|
|
944
|
+
var beaf35555 = MetaNum.BEAF(3, 3, 5, 5, 5);
|
|
945
|
+
checkBool("BEAF(3,3,5,5,5) exact (base kept, [1,0,1] first, [1,4,4,4] last)",
|
|
946
|
+
beaf35555.array.length <= MetaNum.maxRows
|
|
947
|
+
&& JSON.stringify(beaf35555.array[0]) === JSON.stringify([3638334640023.7783, 7625597484984])
|
|
948
|
+
&& JSON.stringify(beaf35555.array[1]) === JSON.stringify([1, 0, 1])
|
|
949
|
+
&& JSON.stringify(beaf35555.array[beaf35555.array.length - 1]) === JSON.stringify([1, 4, 4, 4]), true);
|
|
950
|
+
MetaNum.maxRows = _savedRowsBEAF;
|
|
951
|
+
// BEAF(5,5,1,1,1,2) = 5{ω^3+1}5: truncated expansion
|
|
952
|
+
var beaf511112 = MetaNum.BEAF(5, 5, 1, 1, 1, 2);
|
|
953
|
+
checkBool("BEAF(5,5,1,1,1,2) truncated ([10] base, first count 4, last [3,0,0,0,1])",
|
|
954
|
+
JSON.stringify(beaf511112.array[0]) === JSON.stringify([10])
|
|
955
|
+
&& beaf511112.array[1][0] === 4
|
|
956
|
+
&& JSON.stringify(beaf511112.array[beaf511112.array.length - 1]) === JSON.stringify([3, 0, 0, 0, 1])
|
|
957
|
+
&& beaf511112.array.length === MetaNum.maxRows, true);
|
|
958
|
+
|
|
959
|
+
// ─────────────────────────────────────
|
|
960
|
+
// Hardy hierarchy — ALL hardy verifications grouped here
|
|
961
|
+
// reorganization: small-level, per-definition nested exponents, >1e15
|
|
962
|
+
// inputs, MetaNum-object inputs and the 10^^MSI engine limit)
|
|
963
|
+
// hardy(n) = H_α(10); hardy(10) = H_ω(10) = 20; digits of n become CNF coefficients
|
|
964
|
+
// hardy per definition, evaluated from below
|
|
965
|
+
// hardy(1e10) = H_{ω^ω}(10) = H_{ω^10}(10) — EXACT array
|
|
966
|
+
// [3086.036065328153, 9×8], strictly below 10{10}10
|
|
967
|
+
// hardy(1e11) = H_{ω^(ω+1)}(10) — expande(10,10)'s row structure on the
|
|
968
|
+
// definitional base, strictly below 10{ω+1}10
|
|
969
|
+
// monotone: hardy(9999999999) < hardy(1e10) < hardy(10000000001)
|
|
970
|
+
// (moved into the "hardy hierarchy (all cases)" section below
|
|
971
|
+
// reorganization groups every hardy verification together)
|
|
972
|
+
// ─────────────────────────────────────
|
|
973
|
+
console.log("\n=== hardy hierarchy (all cases) ===");
|
|
974
|
+
// -- small levels (exact closed forms) --
|
|
975
|
+
checkOp("hardy(0)", MetaNum.hardy(0), 10, 0);
|
|
976
|
+
checkOp("hardy(9)", MetaNum.hardy(9), 19, 0);
|
|
977
|
+
checkBool("hardy(10) = H_ω(10) = 20", MetaNum.hardy(10).eq(20), true);
|
|
978
|
+
checkBool("hardy(11) = H_{ω+1}(10) = 22", MetaNum.hardy(11).eq(22), true);
|
|
979
|
+
checkBool("hardy(20) = H_{ω*2}(10) = 40", MetaNum.hardy(20).eq(40), true);
|
|
980
|
+
checkBool("hardy(99) = H_{ω*9+9}(10) = 9728", MetaNum.hardy(99).eq(9728), true);
|
|
981
|
+
checkBool("hardy(100) = H_{ω^2}(10) = 10240", MetaNum.hardy(100).eq(10240), true);
|
|
982
|
+
checkBool("hardy(101) = H_{ω^2+1}(10) = 22528", MetaNum.hardy(101).eq(22528), true);
|
|
983
|
+
checkBool("hardy(1234) = H_{ω^3+ω^2*2+ω*3+4}(10) > 10↑↑1000",
|
|
984
|
+
MetaNum.hardy(1234).gt(MetaNum(10).arrow(2)(1000)), true);
|
|
985
|
+
checkBool("hardy monotone: 999 < 1000", MetaNum.hardy(999).lt(MetaNum.hardy(1000)), true);
|
|
986
|
+
checkBool("hardy(12345) > hardy(1234)", MetaNum.hardy(12345).gt(MetaNum.hardy(1234)), true);
|
|
987
|
+
// -- nested exponents, per definition & evaluated from below (v2.0) --
|
|
988
|
+
checkBool("hardy(1e10) = H_{ω^10}(10) exact array [3086.036, 9×8]",
|
|
989
|
+
JSON.stringify(MetaNum.hardy(1e10).array)
|
|
990
|
+
=== JSON.stringify([[3086.036065328153, 9, 9, 9, 9, 9, 9, 9, 9]]), true);
|
|
991
|
+
checkBool("hardy(1e10) < 10{10}10",
|
|
992
|
+
MetaNum.hardy(1e10).lt(MetaNum(10).arrow(10)(10)), true);
|
|
993
|
+
checkBool("hardy(1e11) = H_{ω^(ω+1)}(10) < 10{ω+1}10 (expande)",
|
|
994
|
+
MetaNum.hardy(1e11).lt(MetaNum(10).expande(10)), true);
|
|
995
|
+
checkBool("hardy monotone 9999999999 < 1e10 < 10000000001",
|
|
996
|
+
MetaNum.hardy(9999999999).lt(MetaNum.hardy(1e10))
|
|
997
|
+
&& MetaNum.hardy(1e10).lt(MetaNum.hardy(10000000001)), true);
|
|
998
|
+
checkBool("hardy(1e12) > hardy(1e11) (monotone in scale)",
|
|
999
|
+
MetaNum.hardy(1e12).gt(MetaNum.hardy(1e11)), true);
|
|
1000
|
+
// -- >1e15 inputs (v2.0): scientific-notation strings expand to exact
|
|
1001
|
+
// digits so the digit-CNF reading stays monotone past 1e20 --
|
|
1002
|
+
checkBool("hardy(1e20) < hardy(1e21) < hardy(1e22) (sci-string fix)",
|
|
1003
|
+
MetaNum.hardy(1e20).lt(MetaNum.hardy(1e21))
|
|
1004
|
+
&& MetaNum.hardy(1e21).lt(MetaNum.hardy(1e22)), true);
|
|
1005
|
+
checkBool("hardy(1e15) < hardy(1e16) < hardy(1e17)",
|
|
1006
|
+
MetaNum.hardy(1e15).lt(MetaNum.hardy(1e16))
|
|
1007
|
+
&& MetaNum.hardy(1e16).lt(MetaNum.hardy(1e17)), true);
|
|
1008
|
+
// -- MetaNum-object input (v2.0): structures shadow to their ordinal --
|
|
1009
|
+
// power tower 10^^k → ω^ω^…^ω (k ω's) → H there = 10.epsilonate(k);
|
|
1010
|
+
// letter/ordinal values sit at their own Hardy position → themselves
|
|
1011
|
+
checkBool("hardy(10^^100) = 10{ω^…^ω(100 ωs)}10 = epsilonate(100)",
|
|
1012
|
+
MetaNum.hardy(MetaNum(10).tetr(100)).eq(MetaNum(10).epsilonate(100)), true);
|
|
1013
|
+
checkBool("hardy(MetaNum G600) = Infinity",
|
|
1014
|
+
MetaNum.hardy(MetaNum("G600")).eq(MetaNum.infinity), true);
|
|
1015
|
+
checkBool("hardy(MetaNum arrow(3,9,3)) = Infinity",
|
|
1016
|
+
MetaNum.hardy(MetaNum.arrow(3, 9, 3)).eq(MetaNum.infinity), true);
|
|
1017
|
+
// anything strictly above 10^^MSI exceeds the ε₀ ceiling → Infinity
|
|
1018
|
+
checkBool("hardy(10{3}10) = Infinity (> 10^^MSI)",
|
|
1019
|
+
MetaNum.hardy(MetaNum(10).arrow(3)(10)).isInfinite(), true);
|
|
1020
|
+
// -- the engine limit: hardy(10^^MSI) = 10{ω^…^ω(MSI ω's)}10 (v2.0) --
|
|
1021
|
+
(function () {
|
|
1022
|
+
var MSI = 9007199254740991;
|
|
1023
|
+
checkBool("hardy(10^^MSI) = MetaNum limit 10{ω^…^ω(MSI ω's)}10",
|
|
1024
|
+
MetaNum.hardy(MetaNum(10).tetr(MSI)).eq(MetaNum(10).epsilonate(MSI)), true);
|
|
1025
|
+
checkBool("hardy(10^^(MSI-1)) = epsilonate(MSI-1) (just below the cap)",
|
|
1026
|
+
MetaNum.hardy(MetaNum(10).tetr(MSI - 1)).eq(MetaNum(10).epsilonate(MSI - 1)), true);
|
|
1027
|
+
})();
|
|
1028
|
+
|
|
1029
|
+
// ─────────────────────────────────────
|
|
1030
|
+
// fractional hyperoperation levels
|
|
1031
|
+
// level n+f interpolates geometrically (README rule i): 10{n+f}10 =
|
|
1032
|
+
// 10{n+1}(2·5^f); continuous: f=0 → level n, f=1 → level n+1
|
|
1033
|
+
// ─────────────────────────────────────
|
|
1034
|
+
console.log("\n=== fractional levels ===");
|
|
1035
|
+
(function () {
|
|
1036
|
+
var a = MetaNum(10);
|
|
1037
|
+
var v3 = a.arrow(3)(10), v4 = a.arrow(4)(10);
|
|
1038
|
+
var v32 = a.arrow(3.2)(10), v35 = a.arrow(3.5)(10);
|
|
1039
|
+
checkBool("10{3.0}10 = 10{3}10 (f=0 anchor)", a.arrow(3.0)(10).eq(v3), true);
|
|
1040
|
+
checkBool("monotone 10{3}10 < 10{3.2}10 < 10{3.5}10 < 10{4}10",
|
|
1041
|
+
v3.lt(v32) && v32.lt(v35) && v35.lt(v4), true);
|
|
1042
|
+
// rule (i) verbatim: 10{3.5}10 = 10{4}(2·5^0.5)
|
|
1043
|
+
var theta = MetaNum(2).mul(MetaNum(10).div(2).pow(0.5));
|
|
1044
|
+
checkBool("10{3.5}10 = 10{4}(2·5^0.5)", v35.eq(a.arrow(4)(theta)), true);
|
|
1045
|
+
checkBool("3{2.5}3 between 3{2}3 and 3{3}3",
|
|
1046
|
+
MetaNum(3).arrow(2)(3).lt(MetaNum(3).arrow(2.5)(3)) &&
|
|
1047
|
+
MetaNum(3).arrow(2.5)(3).lt(MetaNum(3).arrow(3)(3)), true);
|
|
1048
|
+
})();
|
|
1049
|
+
|
|
1050
|
+
// ─────────────────────────────────────
|
|
1051
|
+
// non-integer arguments at ordinal levels
|
|
1052
|
+
// expa(10,2.1) = 10{ω+1}2.1 = 10{ω}10{ω}(10^0.1)
|
|
1053
|
+
// (continuity: expa(10,2) = 10{ω}10, expa(10,3) = 10{ω}10{ω}10)
|
|
1054
|
+
// ─────────────────────────────────────
|
|
1055
|
+
console.log("\n=== ordinal-level fractional arguments ===");
|
|
1056
|
+
(function () {
|
|
1057
|
+
var e2 = MetaNum(10).expande(2), e21 = MetaNum(10).expande(2.1),
|
|
1058
|
+
e25 = MetaNum(10).expande(2.5), e3 = MetaNum(10).expande(3);
|
|
1059
|
+
checkBool("expa(10,2) = 10{ω}10", e2.eq(MetaNum(10).aperiote(10)), true);
|
|
1060
|
+
checkBool("expa(10,3) = 10{ω}10{ω}10", e3.eq(MetaNum(10).aperiote(e2)), true);
|
|
1061
|
+
checkBool("expa(10,2.1) = 10{ω}10{ω}(10^0.1)",
|
|
1062
|
+
e21.eq(MetaNum(10).aperiote(MetaNum(10).aperiote(MetaNum(10).pow(0.1)))), true);
|
|
1063
|
+
checkBool("expa monotone 2 < 2.1 < 2.5 < 3",
|
|
1064
|
+
e2.lt(e21) && e21.lt(e25) && e25.lt(e3), true);
|
|
1065
|
+
var m21 = MetaNum(10).multiexpande(2.1);
|
|
1066
|
+
checkBool("muea(10,2.1) = 10{ω+2}2.1 = (10{ω+1})²(10^0.1)",
|
|
1067
|
+
m21.eq(MetaNum(10).expande(MetaNum(10).expande(MetaNum(10).pow(0.1)))), true);
|
|
1068
|
+
checkBool("poea(10,2.1) = 10{ω+3}2.1 = (10{ω+2})²(10^0.1)",
|
|
1069
|
+
MetaNum(10).powerexpande(2.1).eq(
|
|
1070
|
+
MetaNum(10).multiexpande(MetaNum(10).multiexpande(MetaNum(10).pow(0.1)))), true);
|
|
1071
|
+
checkBool("expa(10,3.1) computable", !MetaNum(10).expande(3.1).isNaN(), true);
|
|
1072
|
+
})();
|
|
1073
|
+
|
|
776
1074
|
console.log("\n=== Done ===");
|
|
777
1075
|
|
|
778
1076
|
// ─────────────────────────────────────
|
|
@@ -810,12 +1108,12 @@ checkFormat("GG900", "GG900", "G1.000G900");
|
|
|
810
1108
|
checkFormat("J1000", "J1000", "1.000J1,000");
|
|
811
1109
|
|
|
812
1110
|
// Ordinal (Aa and beyond) - single letter: α + letter + β
|
|
813
|
-
checkFormat("Aa100", "Aa100", "
|
|
1111
|
+
checkFormat("Aa100", "Aa100", "2.000Aa100");
|
|
814
1112
|
checkFormat("Ab400", "Ab400", "1.000Ab400");
|
|
815
1113
|
checkFormat("Ac800", "Ac800", "1.000Ac800");
|
|
816
1114
|
checkFormat("Aj900", "Aj900", "1.000Aj900");
|
|
817
|
-
checkFormat("Ba1000", "Ba1000", "
|
|
818
|
-
checkFormat("Aaa100", "Aaa100", "
|
|
1115
|
+
checkFormat("Ba1000", "Ba1000", "2.000Ba1,000");
|
|
1116
|
+
checkFormat("Aaa100", "Aaa100", "2.000Aaa100");
|
|
819
1117
|
|
|
820
1118
|
// Ordinal with multi-level r0: ordinalLetter + r0Chain (includes α)
|
|
821
1119
|
checkFormat("AaE200", "AaE200", "Aa1.000E200");
|
|
@@ -831,15 +1129,13 @@ checkFormat("Abc100", "Abc100", "1.000Abc100");
|
|
|
831
1129
|
checkFormat("Defg200", "Defg200", "1.000Defg200");
|
|
832
1130
|
|
|
833
1131
|
// Symbols and ε:
|
|
834
|
-
checkFormat("!Aa300", "!Aa300", "!
|
|
1132
|
+
checkFormat("!Aa300", "!Aa300", "!2.000Aa300");
|
|
835
1133
|
checkFormat("@Bb400", "@Bb400", "@1.000Bb400");
|
|
836
1134
|
checkFormat("1ε500", "1ε500", "1.000ε500");
|
|
837
1135
|
|
|
838
|
-
// ─────────────────────────────────────
|
|
839
1136
|
// Reciprocal of large numbers (sign=2) format tests
|
|
840
1137
|
// smallNotationUseE=true → E-<formatted mag>
|
|
841
1138
|
// smallNotationUseE=false → <formatted value>⁻¹
|
|
842
|
-
// ─────────────────────────────────────
|
|
843
1139
|
console.log("\n=== reciprocal format tests ===");
|
|
844
1140
|
|
|
845
1141
|
// Parsing: verify sign=2 and array structure
|
|
@@ -863,12 +1159,275 @@ checkFormat("1/F10 (useE=true)", "1/F10", "E-1.000F9");
|
|
|
863
1159
|
// 1/F500 → "1.000F500⁻¹"
|
|
864
1160
|
// 1/G200 → "1.000G200⁻¹"
|
|
865
1161
|
// 1/F10 → "1.000F10⁻¹"
|
|
866
|
-
var
|
|
867
|
-
|
|
1162
|
+
var _FMT = (typeof FORMAT_OPTIONS !== "undefined" && FORMAT_OPTIONS) ? FORMAT_OPTIONS : require("./format-metanum.js").FORMAT_OPTIONS;
|
|
1163
|
+
var _savedUseE = _FMT.smallNotationUseE;
|
|
1164
|
+
_FMT.smallNotationUseE = false;
|
|
868
1165
|
checkFormat("E-EE1000 (useE=false)", "E-EE1000", "EE1.000E1,000⁻¹");
|
|
869
1166
|
checkFormat("1/F500 (useE=false)", "1/F500", "1.000F500⁻¹");
|
|
870
1167
|
checkFormat("1/G200 (useE=false)", "1/G200", "1.000G200⁻¹");
|
|
871
1168
|
checkFormat("1/F10 (useE=false)", "1/F10", "1.000F10⁻¹");
|
|
872
|
-
|
|
1169
|
+
_FMT.smallNotationUseE = _savedUseE;
|
|
1170
|
+
|
|
1171
|
+
console.log("\n=== format α correctness ===");
|
|
1172
|
+
// format α correctness
|
|
1173
|
+
checkFormat("hardy(1120) single α", MetaNum.hardy(1120), "F4.398E13");
|
|
1174
|
+
checkFormat("hardy(4150) real α", MetaNum.hardy(4150), "2.300G5");
|
|
1175
|
+
checkFormat("nested arrow single α", MetaNum.arrow(3, MetaNum.arrow(3, 4, 3), 3), "AaGF7.626E12");
|
|
1176
|
+
checkFormat("canonical all-8s keeps α=1 (G600)", "G600", "1.000G600");
|
|
1177
|
+
|
|
1178
|
+
// ─────────────────────────────────────
|
|
1179
|
+
// display rules: at most TWO letter types, one α, multiLetterLimit symbol
|
|
1180
|
+
// carry — a cascade that would spell 20 letter types keeps its top two levels,
|
|
1181
|
+
// and a combination longer than multiLetterLimit switches to !αAaβ
|
|
1182
|
+
// ─────────────────────────────────────
|
|
1183
|
+
checkFormat("20-row cascade compresses to one type", MetaNum.h10000(3, 10), "1.000Iccc19");
|
|
1184
|
+
checkFormat("10-letter level carries to !…Aa9 (definition digits)", MetaNum.iter(3, 10), "!2.222Aa9");
|
|
1185
|
+
checkFormat("5-letter level carries to !…Aa4 (definition digits)", m3.iter(5), "!2.222Aa4");
|
|
1186
|
+
checkFormat("symbol carry stacks: apix(3,10) → @…Aa10", m3.aperixxate(10), "@2.000Aa10");
|
|
1187
|
+
checkFormat("symbol carry stacks: apix(3,5) → @…Aa5", m3.aperixxate(5), "@2.000Aa5");
|
|
1188
|
+
checkFormat("short diagonal keeps the letter form", m3.aperixxate(3), "!2.000Aaaa10");
|
|
1189
|
+
checkFormat("cascade inner α stays [1,10) (AbAa600)", "AbAa600", "Ab1.000Aa600");
|
|
1190
|
+
|
|
1191
|
+
// Γ-canonical law test: long descending count-1 chains
|
|
1192
|
+
// format at their bisect-exact letter on the engine's smooth arrow curve;
|
|
1193
|
+
// ordinal-row levels use Aa-notation (the engine's fractional-arg curve is
|
|
1194
|
+
// quantized at level ≥ 20, so 3{20}3 formats via its [1,20] ordinal row)
|
|
1195
|
+
checkFormat("GE12 single-alpha", "GE12", "G1.000E12");
|
|
1196
|
+
checkFormat("arrow(3,19,3) structural V...U...", MetaNum.arrow(3, 19, 3), "V2.376U2");
|
|
1197
|
+
checkFormat("arrow(3,20,3) structural W...V...", MetaNum.arrow(3, 20, 3), "W2.376V2");
|
|
1198
|
+
checkFormat("arrow(3,1000,3) αAaβ", MetaNum.arrow(3, 1000, 3), "2.376Aa999");
|
|
1199
|
+
|
|
1200
|
+
// ─────────────────────────────────────
|
|
1201
|
+
// maxCols/maxRows = 20 — r0 overflow levels must become
|
|
1202
|
+
// finite-level ordinal rows [count, level], not be dropped
|
|
1203
|
+
// ─────────────────────────────────────
|
|
1204
|
+
console.log("\n=== maxCols/maxRows = 20 (Z10) ===");
|
|
1205
|
+
var _savedCols = MetaNum.maxCols, _savedRows = MetaNum.maxRows;
|
|
1206
|
+
MetaNum.maxCols = 20; MetaNum.maxRows = 20;
|
|
1207
|
+
(function () {
|
|
1208
|
+
var exp = [[10000000000]];
|
|
1209
|
+
for (var i = 0; i < 19; i++) exp[0].push(8);
|
|
1210
|
+
var z20 = new MetaNum("Z10");
|
|
1211
|
+
checkArr("Z10 @ maxCols=20", z20, exp.concat([[8, 20], [8, 21]]));
|
|
1212
|
+
var z20rt = new MetaNum(z20.toString());
|
|
1213
|
+
checkBool("Z10 @ maxCols=20 roundtrip", z20.eq(z20rt), true);
|
|
1214
|
+
MetaNum.maxCols = 100; MetaNum.maxRows = 100;
|
|
1215
|
+
var z20v100 = new MetaNum(z20.toString());
|
|
1216
|
+
checkBool("Z10 @20 toString reparsed @100 ~= Z10 @100", z20v100.eq(new MetaNum("Z10")), true);
|
|
1217
|
+
})();
|
|
1218
|
+
MetaNum.maxCols = _savedCols; MetaNum.maxRows = _savedRows;
|
|
1219
|
+
|
|
1220
|
+
// ─────────────────────────────────────
|
|
1221
|
+
// symbol layer semantics (numeric-level assertions)
|
|
1222
|
+
// ! = one ω^ layer: !Aa5 = 10{ω^ω}5 = 10{ω^5}5 (FS of ω^ω at 5)
|
|
1223
|
+
// @ = two layers: @Aa5 = 10{ω^ω^ω}5 = 10{ω^(ω^5)}5
|
|
1224
|
+
// # = three layers; !Ab5 = 10{ω^(ω+1)}5
|
|
1225
|
+
// ─────────────────────────────────────
|
|
1226
|
+
console.log("\n=== symbol layer semantics ===");
|
|
1227
|
+
(function () {
|
|
1228
|
+
var om5row = JSON.stringify([1, 0, 0, 0, 0, 0, 1]); // [1 | ω^5] marker row
|
|
1229
|
+
var x = MetaNum("!Aa5");
|
|
1230
|
+
checkBool("!Aa5 = 10{ω^5}5 marker row", JSON.stringify(x.array[1]) === om5row && x.array.length === 2, true);
|
|
1231
|
+
checkBool("!Aa5 de-layers to Aaaaaa5", x.eq(MetaNum("Aaaaaa5")), true);
|
|
1232
|
+
checkBool("!1.000Aa5 = !Aa5 (binary form α=1)", MetaNum("!1.000Aa5").eq(x), true);
|
|
1233
|
+
var y = MetaNum("@Aa5");
|
|
1234
|
+
checkBool("@Aa5 = !Aaaaaa5 (two ω^ layers)", y.eq(MetaNum("!Aaaaaa5")), true);
|
|
1235
|
+
checkBool("@Aa5 layer=1 with ω^5 row", y.layer === 1 && JSON.stringify(y.array[1]) === om5row, true);
|
|
1236
|
+
checkBool("@1.000Aa5 = @Aa5", MetaNum("@1.000Aa5").eq(y), true);
|
|
1237
|
+
var z = MetaNum("#Aa5");
|
|
1238
|
+
checkBool("#Aa5 = @Aaaaaa5 (three ω^ layers)", z.eq(MetaNum("@Aaaaaa5")), true);
|
|
1239
|
+
checkBool("#Aa5 layer=2", z.layer === 2, true);
|
|
1240
|
+
var ab = MetaNum("!Ab5");
|
|
1241
|
+
checkBool("!Ab5 = 10{ω^(ω+1)}5 (layer 1, row [1,1,1])",
|
|
1242
|
+
ab.layer === 1 && JSON.stringify(ab.array[1]) === JSON.stringify([1, 1, 1]), true);
|
|
1243
|
+
checkBool("!Ba5 = 10{ω^(ω*2)}5 (layer 1, row [1,0,2])",
|
|
1244
|
+
MetaNum("!Ba5").layer === 1 && JSON.stringify(MetaNum("!Ba5").array[1]) === JSON.stringify([1, 0, 2]), true);
|
|
1245
|
+
checkBool("layer monotonicity Aa5 < !Aa5 < @Aa5 < #Aa5",
|
|
1246
|
+
MetaNum("Aa5").lt(x) && x.lt(y) && y.lt(z), true);
|
|
1247
|
+
checkBool("!Ab5 > !Aa5", ab.gt(x), true);
|
|
1248
|
+
checkRT("!Aa5", "!Aa5");
|
|
1249
|
+
checkRT("@Aa5", "@Aa5");
|
|
1250
|
+
checkRT("#Aa5", "#Aa5");
|
|
1251
|
+
checkRT("!Ab5", "!Ab5");
|
|
1252
|
+
})();
|
|
1253
|
+
|
|
1254
|
+
console.log("\n=== two-letter rule ===");
|
|
1255
|
+
(function () {
|
|
1256
|
+
// Rule (2-letter rule): a display may use at most 2 letter COMBINATIONS in its
|
|
1257
|
+
// finite hyper-op chain — VαEβ → VαFβ → … → VαVβ — never a third type mixed
|
|
1258
|
+
// in (e.g. "VFαEβ"). The rule is about the single-uppercase finite letters
|
|
1259
|
+
// (E,F,G,...,Z): the Aa/Ab/... two-char tokens are ordinal-structure
|
|
1260
|
+
// markers (same role as !/@/#! symbols), and an "E" inside a number
|
|
1261
|
+
// ("7.626E12") is scientific notation, not a letter op — both are excluded
|
|
1262
|
+
// from the count. The reference formatter (format-powiainanum.js) produces
|
|
1263
|
+
// the same shapes: "J" + "GF7.626E12" for arrow(3,arrow(3,4,3),3).
|
|
1264
|
+
var samples = ["V10", "VE10", "VF10", "W10", "G1.161G897", "AaGF7.626E12",
|
|
1265
|
+
"2.397G5", "1.285H8", "2.376W2", "1.125Aa99", "F4.398E13", "GF7.626E12"];
|
|
1266
|
+
var allOk = true;
|
|
1267
|
+
for (var i = 0; i < samples.length; i++) {
|
|
1268
|
+
var disp = format(MetaNum(samples[i]));
|
|
1269
|
+
// strip scientific-notation E inside numbers ("7.626E12"), then count
|
|
1270
|
+
// distinct single-uppercase letters (Aa-style ordinal tokens excluded)
|
|
1271
|
+
var stripped = disp.replace(/(\d(?:\.\d+)?)E(\d[\d,]*)/g, "$1$2");
|
|
1272
|
+
var tokens = stripped.match(/[A-Z](?![a-z])/g) || [];
|
|
1273
|
+
var types = {};
|
|
1274
|
+
for (var t = 0; t < tokens.length; t++) types[tokens[t]] = true;
|
|
1275
|
+
var nTypes = Object.keys(types).length;
|
|
1276
|
+
if (nTypes > 2) {
|
|
1277
|
+
allOk = false;
|
|
1278
|
+
console.log(" >2 finite letter types in", samples[i], "→", disp);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
checkBool("all displays use ≤ 2 finite letter types", allOk, true);
|
|
1282
|
+
checkBool("arrow(3,4.1,3) display has exactly G only (VαEβ→…→VαVβ law)",
|
|
1283
|
+
(format(MetaNum.arrow(3, 4.1, 3)).match(/[A-Z][a-z]?/g) || []).every(function (tk) { return tk === "G"; }), true);
|
|
1284
|
+
// round-trip of the Aa-prefixed sci-arg chain (parse bug fix in v2.0:
|
|
1285
|
+
// "AaGF7.626E12" used to eat only the "7" and drop ".626E12")
|
|
1286
|
+
checkBool("AaGF7.626E12 parses with full sci arg",
|
|
1287
|
+
MetaNum("AaGF7.626E12").array[0][1] === 7625999999998
|
|
1288
|
+
&& MetaNum("AaGF7.626E12").array.length === 2, true);
|
|
1289
|
+
checkBool("AaGF7.626E12 round-trips through format",
|
|
1290
|
+
format(MetaNum(format(MetaNum("AaGF7.626E12")))) === "AaGF7.626E12", true);
|
|
1291
|
+
})();
|
|
1292
|
+
|
|
1293
|
+
// ─────────────────────────────────────
|
|
1294
|
+
// hardy hierarchy — display-form verification (all user cases)
|
|
1295
|
+
// ≤2 letter types per display; diagonal cascades compress to the
|
|
1296
|
+
// structural two-letter form or the αAaβ polarize diagonal;
|
|
1297
|
+
// repeatLetterThreshold+1 repeated single letters carry to the next
|
|
1298
|
+
// ─────────────────────────────────────
|
|
1299
|
+
console.log("\n=== hardy hierarchy display forms ===");
|
|
1300
|
+
checkFormat("arrow(3,9,3) → L…K…", MetaNum.arrow(3, 9, 3), "L2.376K2");
|
|
1301
|
+
checkFormat("arrow(3,10,3) → M(10^0.376)L2", MetaNum.arrow(3, 10, 3), "M2.376L2");
|
|
1302
|
+
checkFormat("arrow(4,9,4) → LLK…K…", MetaNum.arrow(4, 9, 4), "LLK3.550K3");
|
|
1303
|
+
checkFormat("arrow(5,9,5) → LLLKK…K…", MetaNum.arrow(5, 9, 5), "LLLKK4.669K4");
|
|
1304
|
+
checkBool("arrow(6,9,6) carries to …M5 (threshold+1 repeats)",
|
|
1305
|
+
/M5$/.test(format(MetaNum.arrow(6, 9, 6))), true);
|
|
1306
|
+
checkFormat("arrow(3,22,3) → Y…X…", MetaNum.arrow(3, 22, 3), "Y2.376X2");
|
|
1307
|
+
checkFormat("arrow(3,23,3) → Z…Y…", MetaNum.arrow(3, 23, 3), "Z2.376Y2");
|
|
1308
|
+
checkFormat("arrow(3,24,3) → 2.376Aa23 (Aa diagonal)", MetaNum.arrow(3, 24, 3), "2.376Aa23");
|
|
1309
|
+
checkFormat("arrow(3,100,3) → 2.376Aa99", MetaNum.arrow(3, 100, 3), "2.376Aa99");
|
|
1310
|
+
checkFormat("arrow(10,10000,10) → 1.000Aa10,000", MetaNum.arrow(10, 10000, 10), "2.000Aa10,000");
|
|
1311
|
+
checkFormat("nested arrow(3,arrow(3,100,3),3) → Aa2.376Aa99",
|
|
1312
|
+
MetaNum.arrow(3, MetaNum.arrow(3, 100, 3), 3), "Aa2.376Aa99");
|
|
1313
|
+
checkFormat("nested arrow(3,arrow(10,10000,10),3) → Aa1.000Aa10,000",
|
|
1314
|
+
MetaNum.arrow(3, MetaNum.arrow(10, 10000, 10), 3), "Aa2.000Aa10,000");
|
|
1315
|
+
// every display uses at most 2 distinct letter tokens (≤2-types rule)
|
|
1316
|
+
(function () {
|
|
1317
|
+
var cases = [
|
|
1318
|
+
MetaNum.arrow(3, 9, 3), MetaNum.arrow(4, 9, 4), MetaNum.arrow(5, 9, 5),
|
|
1319
|
+
MetaNum.arrow(3, 22, 3), MetaNum.arrow(3, 23, 3), MetaNum.arrow(3, 24, 3),
|
|
1320
|
+
MetaNum.arrow(3, 100, 3), MetaNum.arrow(10, 10000, 10),
|
|
1321
|
+
MetaNum.arrow(3, MetaNum.arrow(3, 100, 3), 3),
|
|
1322
|
+
];
|
|
1323
|
+
var all2 = true;
|
|
1324
|
+
for (var ci = 0; ci < cases.length; ci++) {
|
|
1325
|
+
var toks = (format(cases[ci]).match(/[A-Z][a-z]*/g) || []).filter(function (t) { return t !== "E"; });
|
|
1326
|
+
// strip the structural E inside numbers first, then count distinct tokens
|
|
1327
|
+
var s = format(cases[ci]).replace(/(\d(?:\.\d+)?)E[\d,]+/g, "$1");
|
|
1328
|
+
toks = (s.match(/[A-Z][a-z]*/g) || []);
|
|
1329
|
+
var seen = {};
|
|
1330
|
+
for (var ti = 0; ti < toks.length; ti++) seen[toks[ti]] = 1;
|
|
1331
|
+
if (Object.keys(seen).length > 2) { all2 = false; console.log(" >2 types:", format(cases[ci])); }
|
|
1332
|
+
}
|
|
1333
|
+
checkBool("all diagonal-cascade displays use ≤ 2 letter types", all2, true);
|
|
1334
|
+
})();
|
|
1335
|
+
|
|
1336
|
+
// ─────────────────────────────────────────────────────────────────
|
|
1337
|
+
// v2.0: rule 3 unification + pure dlsdl diagonal [2,10) convention
|
|
1338
|
+
// ─────────────────────────────────────────────────────────────────
|
|
1339
|
+
console.log("\n=== diagonal letter convention ===");
|
|
1340
|
+
// rule 3: n{λ}b = n{λ[b]}n
|
|
1341
|
+
checkBool("aper(3,5) = 3{5}3", MetaNum.aperiote(3,5).eq(MetaNum(3).arrow(5)(3)), true);
|
|
1342
|
+
// diagonal letters (ending in 'a'): integer arguments all anchor at 2.000
|
|
1343
|
+
[10, 11, 50, 100].forEach(function (b) {
|
|
1344
|
+
checkFormat("10{100}" + b + " → 2.000Aa100", MetaNum.arrow(10, 100, b), "2.000Aa100");
|
|
1345
|
+
});
|
|
1346
|
+
checkFormat("11{100}11 → 2.000Aa100", MetaNum.arrow(11, 100, 11), "2.000Aa100");
|
|
1347
|
+
// structured count climbs to its smooth diagonal mantissa
|
|
1348
|
+
checkFormat("10{100}(10{93}10) → 2.002Aa100",
|
|
1349
|
+
MetaNum.arrow(10, 100, MetaNum.arrow(10, 93, 10)), "2.002Aa100");
|
|
1350
|
+
// non-diagonal letters keep the [1,10) convention
|
|
1351
|
+
checkFormat("Ab100 → 1.000Ab100", MetaNum("Ab100"), "1.000Ab100");
|
|
1352
|
+
// symbol de-layering
|
|
1353
|
+
checkFormat("!Aa3 → 2.000Aaaa10", MetaNum("!Aa3"), "2.000Aaaa10");
|
|
1354
|
+
checkFormat("@Aa3 → !2.000Aaaa10", MetaNum("@Aa3"), "!2.000Aaaa10");
|
|
1355
|
+
// parser roundtrip of the new canonical forms
|
|
1356
|
+
checkBool("parse 2.000Aaaa10", MetaNum("2.000Aaaa10").format() === "2.000Aaaa10", true);
|
|
1357
|
+
checkBool("parse !2.000Aaaa10", MetaNum("!2.000Aaaa10").format() === "!2.000Aaaa10", true);
|
|
1358
|
+
checkBool("parse 2.002Aa100", MetaNum("2.002Aa100").format() === "2.002Aa100", true);
|
|
1359
|
+
// hardy(1e10+k) must not blow the stack
|
|
1360
|
+
(function () {
|
|
1361
|
+
var ok = true;
|
|
1362
|
+
for (var k = 0; k <= 60; k++) {
|
|
1363
|
+
try { MetaNum.hardy(1e10 + k); } catch (e) { ok = false; console.log("hardy threw at", 1e10 + k, e.message); }
|
|
1364
|
+
}
|
|
1365
|
+
checkBool("hardy(1e10+0..60) no throw", ok, true);
|
|
1366
|
+
})();
|
|
1367
|
+
// cross-config stability for the new cases
|
|
1368
|
+
(function () {
|
|
1369
|
+
var ref = null, stable = true;
|
|
1370
|
+
[10, 20, 50, 100].forEach(function (c) {
|
|
1371
|
+
MetaNum.maxRows = c; MetaNum.maxCols = c;
|
|
1372
|
+
var f = format(MetaNum.arrow(10, 100, MetaNum.arrow(10, 93, 10)));
|
|
1373
|
+
if (ref === null) ref = f;
|
|
1374
|
+
else if (f !== ref) { stable = false; console.log("cfg" + c + " drift: " + f + " vs " + ref); }
|
|
1375
|
+
});
|
|
1376
|
+
MetaNum.maxRows = 20; MetaNum.maxCols = 20;
|
|
1377
|
+
checkBool("v2.0: 10{100}(10{93}10) cross-config stable (" + ref + ")", stable, true);
|
|
1378
|
+
})();
|
|
1379
|
+
|
|
1380
|
+
// ─────────────────────────────────────
|
|
1381
|
+
// cross-config stability: identical formats at
|
|
1382
|
+
// maxRows = maxCols = 10 / 20 / 50 / 100 (±1 in the last shown digit)
|
|
1383
|
+
// ─────────────────────────────────────
|
|
1384
|
+
console.log("\n=== cross-config stability ===");
|
|
1385
|
+
(function () {
|
|
1386
|
+
var cases = [[3, 9, 3], [3, 10, 3], [4, 9, 4], [5, 9, 5], [6, 9, 6],
|
|
1387
|
+
[3, 22, 3], [3, 23, 3], [3, 24, 3], [3, 39, 3], [3, 100, 3],
|
|
1388
|
+
[10, 25, 10], [10, 10000, 10]];
|
|
1389
|
+
var cfgs = [10, 20, 50, 100];
|
|
1390
|
+
var stable = true;
|
|
1391
|
+
for (var i = 0; i < cases.length; i++) {
|
|
1392
|
+
var ref = null;
|
|
1393
|
+
for (var c = 0; c < cfgs.length; c++) {
|
|
1394
|
+
MetaNum.maxRows = cfgs[c]; MetaNum.maxCols = cfgs[c];
|
|
1395
|
+
var f = format(MetaNum.arrow(cases[i][0], cases[i][1], cases[i][2]));
|
|
1396
|
+
if (ref === null) ref = f;
|
|
1397
|
+
else if (f !== ref) {
|
|
1398
|
+
// allow ±1 in the last displayed digit
|
|
1399
|
+
var a = ref.match(/(\d+(?:\.\d+)?)(?!.*\d)/), b = f.match(/(\d+(?:\.\d+)?)(?!.*\d)/);
|
|
1400
|
+
if (!a || !b || Math.abs(Number(a[1]) - Number(b[1])) > 1.5 * Math.pow(10, -(a[1].split(".")[1] || "").length + 1)) {
|
|
1401
|
+
stable = false;
|
|
1402
|
+
console.log(" config drift [" + cases[i] + "] " + ref + " vs @" + cfgs[c] + " " + f);
|
|
1403
|
+
} else { ref = f; }
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
MetaNum.maxRows = 20; MetaNum.maxCols = 20;
|
|
1408
|
+
checkBool("formats identical across maxRows/maxCols = 10/20/50/100 (±1 last digit)", stable, true);
|
|
1409
|
+
// clamped bounds: values below 10 and above 1000 snap inside
|
|
1410
|
+
MetaNum.maxRows = 5; checkBool("maxRows clamps up to 10", MetaNum.maxRows === 10, true);
|
|
1411
|
+
MetaNum.maxRows = 5000; checkBool("maxRows clamps down to 1000", MetaNum.maxRows === 1000, true);
|
|
1412
|
+
MetaNum.maxRows = 20;
|
|
1413
|
+
})();
|
|
1414
|
+
|
|
1415
|
+
console.log("\n=== MetaNum(...).format() instance method ===");
|
|
1416
|
+
(function () {
|
|
1417
|
+
function checkFmtEq(name, gotStr, expected) {
|
|
1418
|
+
var pass = gotStr === expected;
|
|
1419
|
+
console.log((pass ? "PASS" : "FAIL") + " | " + name + " | " + gotStr
|
|
1420
|
+
+ (pass ? "" : " (expected " + expected + ")"));
|
|
1421
|
+
}
|
|
1422
|
+
checkFmtEq("G600.format()", MetaNum("G600").format(), "1.000G600");
|
|
1423
|
+
checkFmtEq("hardy(4166).format()", MetaNum.hardy(4166).format(), "2.397G5");
|
|
1424
|
+
checkFmtEq("arrow(3,4.1,3).format()", MetaNum.arrow(3, 4.1, 3).format(), "G1.161G897");
|
|
1425
|
+
checkFmtEq("small 0.5.format()", MetaNum(0.5).format(), "0.500");
|
|
1426
|
+
checkFmtEq("format(2) precision arg", MetaNum(1234.5678).format(2), "1,234");
|
|
1427
|
+
checkFmtEq(".format() matches module format(FE400)",
|
|
1428
|
+
MetaNum("FE400").format(), format(MetaNum("FE400")));
|
|
1429
|
+
})();
|
|
1430
|
+
|
|
1431
|
+
console.log("\n=== format tests Done ===");
|
|
1432
|
+
|
|
873
1433
|
|
|
874
|
-
console.log("\n=== format tests Done ===");
|