diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-09-09 10:31:05 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-09-09 10:31:05 -0400 |
| commit | b2dcd558850f17370eae054418a68105087cda14 (patch) | |
| tree | 97f3007a393e001cc8466fbeba7d41f9dc14ff2c /docs | |
| parent | 3bf6ad2285abfca649580f0fb7a132a30f2433fc (diff) | |
Use Javascript % for Modulus (|) to get correct rounding
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/bqn.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/bqn.js b/docs/bqn.js index c294878d..9a1838de 100644 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -233,6 +233,14 @@ let abs = (x,w) => { if (isnum(x)) return Math.abs(x); throw Error("|𝕩: Argument must be a number"); } +let abs_mod = (x,w) => { + if (!has(w)) return abs(x,w); + if (isnum(x)&&isnum(w)) { + let r = x%w; + return ((x<0)!=(w<0) && r!=0) ? r+w : r; + } + throw Error("𝕨|𝕩: Arguments must be numbers"); +} let lesseq = (x,w) => { let s=typeof w, t=typeof x; if (s==="function"||t==="function") throw Error("𝕨≤𝕩: Cannot compare operations"); @@ -386,6 +394,9 @@ let [runtime,setPrims] = run( ,[[0,184],[4055,3],[4063,3],[4067,3],[4080,3],[4092,3],[4101,3],[4107,2],[4136,3],[4168,2],[4185,4],[4247,5],[4283,3],[4290,5],[4348,4],[4414,3],[4469,3],[4480,4],[4545,9],[4614,5],[4691,5],[4758,4],[4814,8],[4986,8],[5143,3],[5188,3],[5237,3],[5354,6],[5439,3],[5463,7],[5577,3],[5639,4],[5710,6],[5774,3],[5814,5],[5891,3],[5908,14],[6088,3],[6134,3],[6154,3],[6171,4],[6229,4],[6305,5],[6379,3],[6438,0],[6449,4],[6529,3],[6539,3],[6546,3],[6560,3],[6568,3],[6606,5],[6643,5],[6670,3],[6674,3],[6688,16],[6983,3],[7008,3],[7033,3],[7060,3],[7119,4],[7219,7],[7416,7],[7462,14],[7686,5],[7765,3],[7773,6],[7800,5],[7821,6],[7848,11],[8181,9],[8338,4],[8414,7],[8526,7],[8643,3],[8751,4],[8813,8],[8925,8],[8999,7],[9061,9],[9219,9],[9367,4],[9478,8],[9692,3],[9736,3],[9873,2],[9894,14],[10019,9],[10201,10],[10274,3],[10300,10],[10708,4],[10813,3],[10887,3],[10938,4],[11065,4],[11181,2],[11189,6],[11204,2],[11263,3],[11271,3],[11279,3],[11299,8],[11374,3],[11382,3],[11390,3],[11398,3],[11406,3],[11414,3],[11425,3],[11446,7],[11487,6],[11706,4],[11806,3],[11849,5],[11987,3],[12034,3],[12060,3],[12093,3],[12137,3],[12185,3],[12197,3],[12270,2],[12296,4],[12332,3],[12347,3],[12376,3],[12391,3],[12409,3],[12423,3],[12433,3],[12485,6],[12513,3],[12541,3],[12549,3],[12557,5],[12592,12],[12765,3],[12776,3],[12796,3],[12816,3],[12827,3],[12838,3],[12853,7],[12926,6],[12972,3],[12990,3],[12997,6],[13032,10],[13209,4],[13265,11],[13466,4],[13533,3],[13558,2],[13573,3],[13600,7],[13741,3],[13770,3],[13780,3],[13799,3],[13809,3],[13818,3],[13828,3],[13845,11],[13918,6],[14021,8],[14099,3],[14107,3],[14149,7],[14175,9],[14421,5],[14437,6],[14559,5],[14592,6],[14621,3],[14631,3],[14641,4],[14680,4],[14703,3],[14711,3],[14736,6],[14832,2],[14882,8],[15063,11],[15268,3],[15327,3],[15354,3],[15371,3],[15388,8],[15570,3],[15584,3],[15615,2],[15649,3],[15684,3],[15705,3],[15726,5],[15797,3],[15817,8],[16047,3],[16115,3],[16145,3],[16176,3],[16210,5],[16277,3],[16286,3],[16299,3],[16303,3],[16311,3],[16321,2],[16335,2],[16350,6],[16444,3],[16454,3],[16461,9],[16595,3],[16621,3],[16639,3],[16663,3],[16684,3],[16695,3],[16708,2],[16712,3],[16748,5],[16850,3],[16897,5],[16920,3],[16937,14],[17221,13],[17418,3],[17461,4],[17544,3],[17580,3],[17609,3],[17620,4],[17656,7],[17793,10],[17983,6],[18018,3],[18083,3],[18111,4],[18134,5],[18145,4],[18156,4],[18167,5],[18187,4],[18262,3],[18295,3],[18325,5],[18350,3],[18416,3],[18430,3],[18441,5],[18540,4],[18669,3],[18693,3],[18739,3],[18772,3],[18801,5],[18833,3],[18869,3],[18895,3],[18923,3],[18945,5],[18955,3],[18988,3],[19008,6],[19023,2],[19031,2],[19039,5],[19077,3],[19087,3],[19103,5],[19154,3],[19179,6],[19288,3],[19328,3],[19369,5],[19419,6],[19556,3],[19564,8],[19621,5],[19650,3],[19665,3],[19715,2],[19733,3],[19754,3],[19772,3],[19801,3],[19820,3],[19839,6],[19918,5],[19933,14],[20097,3],[20118,3],[20134,4],[20190,3],[20222,3],[20305,3],[20339,3],[20368,3],[20385,3],[20402,3]] ); +// Use high-precision modulus (⚇0) +abs_mod.prim=8; runtime[8] = runtime[60](abs_mod,0); + // Allow inverses defined in JS let undo0 = runtime[48]; runtime[48] = f => f.inverse || undo0(f); |
