···37 <div id="tree"></div>
38 </div>
39 <form>
40- <textarea id="area" rows="8"></textarea>
41 <br>
42 <br>
43 <label title="can be slow with big files"><input type="checkbox" id="wantHex" checked="checked"> with hex dump</label>
···37 <div id="tree"></div>
38 </div>
39 <form>
40+ <textarea id="area" rows="8" placeholder="Paste hex or base64 or PEM encoded ASN.1 BER or DER structures here, or load a file."></textarea>
41 <br>
42 <br>
43 <label title="can be slow with big files"><input type="checkbox" id="wantHex" checked="checked"> with hex dump</label>
+13-7
int10.js
···13// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1516-let max = 10000000000000; // biggest 10^n integer that can still fit 2^53 when multiplied by 256
01718export class Int10 {
19 /**
···2627 /**
28 * Multiply value by m and add c.
29- * @param {number} m - multiplier, must be < =256
30- * @param {number} c - value to add
31 */
32 mulAdd(m, c) {
033 // assert(m <= 256)
034 let b = this.buf,
35 l = b.length,
36 i, t;
···7172 /**
73 * Convert to decimal string representation.
74- * @param {*} base - optional value, only value accepted is 10
075 */
76- toString(base) {
77- if ((base || 10) != 10)
78- throw 'only base 10 is supported';
79 let b = this.buf,
80 s = b[b.length - 1].toString();
81 for (let i = b.length - 2; i >= 0; --i)
···86 /**
87 * Convert to Number value representation.
88 * Will probably overflow 2^53 and thus become approximate.
089 */
90 valueOf() {
91 let b = this.buf,
···9798 /**
99 * Return value as a simple Number (if it is <= 10000000000000), or return this.
0100 */
101 simplify() {
102 let b = this.buf;
···13// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1516+/** Biggest 10^n integer that can still fit 2^53 when multiplied by 256. */
17+const max = 10000000000000;
1819export class Int10 {
20 /**
···2728 /**
29 * Multiply value by m and add c.
30+ * @param {number} m - multiplier, must be 0<m<=256
31+ * @param {number} c - value to add, must be c>=0
32 */
33 mulAdd(m, c) {
34+ // assert(m > 0)
35 // assert(m <= 256)
36+ // assert(c >= 0)
37 let b = this.buf,
38 l = b.length,
39 i, t;
···7475 /**
76 * Convert to decimal string representation.
77+ * @param {number} [base=10] - optional value, only value accepted is 10
78+ * @returns {string} The decimal string representation.
79 */
80+ toString(base = 10) {
81+ if (base != 10)
82+ throw new Error('only base 10 is supported');
83 let b = this.buf,
84 s = b[b.length - 1].toString();
85 for (let i = b.length - 2; i >= 0; --i)
···90 /**
91 * Convert to Number value representation.
92 * Will probably overflow 2^53 and thus become approximate.
93+ * @returns {number} The numeric value.
94 */
95 valueOf() {
96 let b = this.buf,
···102103 /**
104 * Return value as a simple Number (if it is <= 10000000000000), or return this.
105+ * @returns {number | Int10} The simplified value.
106 */
107 simplify() {
108 let b = this.buf;