From 43f8f00ef5e96a5a188bae0e31e01d8774aefde4 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Thu, 26 Dec 2013 17:35:42 -0500 Subject: [PATCH] version bump 0.4.0: improvements across the board - Proper fraction handling (using frac.cont) - Better handling of negative number cases - More tests! --- package.json | 2 +- ssf.js | 67 +++--- ssf.md | 125 ++++++++--- ssf_node.js | 67 +++--- test/fraction.js | 14 ++ test/fraction.json | 107 ++++++++++ test/general.js | 12 ++ test/general.json | 516 +++++++++++++++++++++++++++++++++++++++++++++ test/implied.json | 513 -------------------------------------------- 9 files changed, 820 insertions(+), 603 deletions(-) create mode 100644 test/fraction.js create mode 100644 test/fraction.json create mode 100644 test/general.js create mode 100644 test/general.json diff --git a/package.json b/package.json index 1dd238d..9fdd20b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssf", - "version": "0.3.1", + "version": "0.4.0", "author": "SheetJS", "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", "keywords": [ "format", "sprintf", "spreadsheet" ], diff --git a/ssf.js b/ssf.js index 7278a26..9318276 100644 --- a/ssf.js +++ b/ssf.js @@ -4,7 +4,8 @@ var make_ssf = function(SSF){ String.prototype.reverse=function(){return this.split("").reverse().join("");}; var _strrev = function(x) { return String(x).reverse(); }; function fill(c,l) { return new Array(l+1).join(c); } -function pad(v,d){var t=String(v);return t.length>=d?t:(fill(0,d-t.length)+t);} +function pad(v,d,c){var t=String(v);return t.length>=d?t:(fill(c||0,d-t.length)+t);} +function rpad(v,d,c){var t=String(v);return t.length>=d?t:(t+fill(c||0,d-t.length));} /* Options */ var opts_fmt = {}; function fixopts(o){for(var y in opts_fmt) if(o[y]===undefined) o[y]=opts_fmt[y];} @@ -64,24 +65,26 @@ var months = [ ['N', 'Nov', 'November'], ['D', 'Dec', 'December'] ]; -var frac = function(x, D, mixed) { - var n1 = Math.floor(x), d1 = 1; - var n2 = n1+1, d2 = 1; - if(x !== n1) while(d1 <= D && d2 <= D) { - var m = (n1 + n2) / (d1 + d2); - if(x === m) { - if(d1 + d2 <= D) { d1+=d2; n1+=n2; d2=D+1; } - else if(d1 > d2) d2=D+1; - else d1=D+1; - break; +var frac = function frac(x, D, mixed) { + var sgn = x < 0 ? -1 : 1; + var B = x * sgn; + var P_2 = 0, P_1 = 1, P = 0; + var Q_2 = 1, Q_1 = 0, Q = 0; + var A = B|0; + while(Q_1 < D) { + A = B|0; + P = A * P_1 + P_2; + Q = A * Q_1 + Q_2; + if((B - A) < 0.0000000001) break; + B = 1 / (B - A); + P_2 = P_1; P_1 = P; + Q_2 = Q_1; Q_1 = Q; } - else if(x < m) { n2 = n1+n2; d2 = d1+d2; } - else { n1 = n1+n2; d1 = d1+d2; } - } - if(d1 > D) { d1 = d2; n1 = n2; } - if(!mixed) return [0, n1, d1]; - var q = Math.floor(n1/d1); - return [q, n1 - q*d1, d1]; + if(Q > D) { Q = Q_1; P = P_1; } + if(Q > D) { Q = Q_2; P = P_2; } + if(!mixed) return [0, sgn * P, Q]; + var q = Math.floor(sgn * P/Q); + return [q, sgn*P - q*Q, Q]; }; var general_fmt = function(v) { if(typeof v === 'boolean') return v ? "TRUE" : "FALSE"; @@ -98,10 +101,9 @@ var general_fmt = function(v) { if(o.length > 11+(v<0?1:0)) o = v.toExponential(5); } else { - o = v.toFixed(11).replace(/(\.[0-9]*[1-9])0*$/,"$1") - if(o.length > 11 + (v<0?1:0)) o = v.toPrecision(6); + o = v.toFixed(11).replace(/(\.[0-9]*[1-9])0*$/,"$1"); + if(o.length > 11 + (v<0?1:0)) o = v.toPrecision(6); } - if(v==0.000000001) console.log(v, o); o = o.replace(/(\.[0-9]*[1-9])0+e/,"$1e").replace(/\.0*e/,"e"); return o.replace("e","E").replace(/\.0*$/,"").replace(/\.([0-9]*[^0])0*$/,".$1").replace(/(E[+-])([0-9])$/,"$1"+"0"+"$2"); } @@ -208,6 +210,11 @@ var write_num = function(type, fmt, val) { } if(fmt[0] === "$") return "$"+write_num(type,fmt.substr(fmt[1]==' '?2:1),val); var r, ff, aval = val < 0 ? -val : val, sign = val < 0 ? "-" : ""; + if((r = fmt.match(/# (\?+) \/ (\d+)/))) { + var den = Number(r[2]), rnd = Math.round(aval * den), base = Math.floor(rnd/den); + var myn = (rnd - base*den), myd = den; + return sign + (base?base:"") + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[2].length) : pad(myn,r[1].length," ") + "/" + pad(myd,r[2].length)); + } switch(fmt) { case "0": return Math.round(val); case "0.0": o = Math.round(val*10); @@ -219,8 +226,9 @@ var write_num = function(type, fmt, val) { case "#,##0": return sign + commaify(String(Math.round(aval))); case "#,##0.0": r = Math.round((val-Math.floor(val))*10); return val < 0 ? "-" + write_num(type, fmt, -val) : commaify(String(Math.floor(val))) + "." + r; case "#,##0.00": r = Math.round((val-Math.floor(val))*100); return val < 0 ? "-" + write_num(type, fmt, -val) : commaify(String(Math.floor(val))) + "." + (r < 10 ? "0"+r:r); - case "# ? / ?": ff = frac(val<0?-val:val, 10, true); return (val<0?"-":"") + ff[0] + " " + ff[1] + "/" + ff[2]; - case "# ?? / ??": ff = frac(val<0?-val:val, 100, true); return (val<0?"-":"") + ff[0] + " " + ff[1] + "/" + ff[2]; + case "# ? / ?": ff = frac(aval, 9, true); return sign + (ff[0]||"") + " " + (ff[1] === 0 ? " " : ff[1] + "/" + ff[2]); + case "# ?? / ??": ff = frac(aval, 99, true); return sign + (ff[0]||"") + " " + (ff[1] ? pad(ff[1],2," ") + "/" + rpad(ff[2],2," ") : " "); + case "# ??? / ???": ff = frac(aval, 999, true); return sign + (ff[0]||"") + " " + (ff[1] ? pad(ff[1],3," ") + "/" + rpad(ff[2],3," ") : " "); default: } throw new Error("unsupported format |" + fmt + "|"); @@ -279,13 +287,16 @@ function eval_fmt(fmt, v, opts, flen) { break; /* Numbers */ case '0': case '#': - var nn = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) nn += c; - out.push({t:'n', v:nn}); break; + o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) o += c; + out.push({t:'n', v:o}); break; case '?': o = fmt[i]; while(fmt[++i] === c) o+=c; q={t:c, v:o}; out.push(q); lst = c; break; case '*': ++i; if(fmt[i] == ' ') ++i; break; // ** case '(': case ')': out.push({t:(flen===1?'t':c),v:c}); ++i; break; + case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + o = fmt[i]; while("0123456789".indexOf(fmt[++i]) > -1) o+=fmt[i]; + out.push({t:'D', v:o}); break; case ' ': out.push({t:c,v:c}); ++i; break; default: if("$-+/():!^&'~{}<>=".indexOf(c) === -1) @@ -312,7 +323,7 @@ function eval_fmt(fmt, v, opts, flen) { out[i].t = 't'; break; case 'n': case '(': var jj = i+1; - while(out[jj] && (out[jj].t == '?' || out[jj].t == ' ' || out[i].t == '(' && (out[jj].t == ')' || out[jj].t == 'n') || out[jj].t == 't' && (out[jj].v == '/' || out[jj].v == '$'))) { + while(out[jj] && ("? D".indexOf(out[jj].t) > -1 || out[i].t == '(' && (out[jj].t == ')' || out[jj].t == 'n') || out[jj].t == 't' && (out[jj].v == '/' || out[jj].v == '$' || (out[jj].v == ' ' && (out[jj+1]||{}).t == '?')))) { if(out[jj].v!==' ') out[i].v += ' ' + out[jj].v; delete out[jj]; ++jj; } @@ -332,7 +343,7 @@ function choose_fmt(fmt, v, o) { var l = fmt.length; switch(fmt.length) { case 1: fmt = [fmt[0], fmt[0], fmt[0], "@"]; break; - case 2: fmt = [fmt[0], fmt[1], fmt[0], "@"]; break; + case 2: fmt = [fmt[0], fmt[fmt[1] === "@"?0:1], fmt[0], "@"]; break; case 4: break; default: throw "cannot find right format for |" + fmt + "|"; } @@ -343,7 +354,7 @@ function choose_fmt(fmt, v, o) { var format = function format(fmt,v,o) { fixopts(o = (o||{})); if(fmt === 0) return general_fmt(v, o); - fmt = table_fmt[fmt]; + if(typeof fmt === 'number') fmt = table_fmt[fmt]; var f = choose_fmt(fmt, v, o); return eval_fmt(f[1], v, o, f[0]); }; diff --git a/ssf.md b/ssf.md index f5710d9..bc654da 100644 --- a/ssf.md +++ b/ssf.md @@ -151,10 +151,9 @@ For numbers, try to display up to 11 digits of the number (the original code if(o.length > 11+(v<0?1:0)) o = v.toExponential(5); } else { - o = v.toFixed(11).replace(/(\.[0-9]*[1-9])0*$/,"$1") - if(o.length > 11 + (v<0?1:0)) o = v.toPrecision(6); - } - if(v==0.000000001) console.log(v, o); + o = v.toFixed(11).replace(/(\.[0-9]*[1-9])0*$/,"$1"); + if(o.length > 11 + (v<0?1:0)) o = v.toPrecision(6); + } o = o.replace(/(\.[0-9]*[1-9])0+e/,"$1e").replace(/\.0*e/,"e"); return o.replace("e","E").replace(/\.0*$/,"").replace(/\.([0-9]*[^0])0*$/,".$1").replace(/(E[+-])([0-9])$/,"$1"+"0"+"$2"); } @@ -353,13 +352,13 @@ For exponents, get the exponent and mantissa and format them separately: ``` if(fmt.indexOf("E") > -1) { - var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1; + var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1; ``` For the special case of engineering notation, "shift" the decimal: ``` - if(fmt == '##0.0E+0') { + if(fmt == '##0.0E+0') { var ee = Number(val.toExponential(0).substr(3))%3; o = (val/Math.pow(10,ee%3)).toPrecision(idx+1+(ee%3)).replace(/^([+-]?)([0-9]*)\.([0-9]*)[Ee]/,function($$,$1,$2,$3) { return $1 + $2 + $3.substr(0,ee) + "." + $3.substr(ee) + "E"; }); } else o = val.toExponential(idx); @@ -375,10 +374,20 @@ TODO: localize the currency: if(fmt[0] === "$") return "$"+write_num(type,fmt.substr(fmt[1]==' '?2:1),val); ``` -The default cases are hard-coded. TODO: actually parse them +Fractions with known denominator are resolved by rounding: ```js>tmp/number.js var r, ff, aval = val < 0 ? -val : val, sign = val < 0 ? "-" : ""; + if((r = fmt.match(/# (\?+) \/ (\d+)/))) { + var den = Number(r[2]), rnd = Math.round(aval * den), base = Math.floor(rnd/den); + var myn = (rnd - base*den), myd = den; + return sign + (base?base:"") + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[2].length) : pad(myn,r[1].length," ") + "/" + pad(myd,r[2].length)); + } +``` + +The default cases are hard-coded. TODO: actually parse them + +```js>tmp/number.js switch(fmt) { case "0": return Math.round(val); case "0.0": o = Math.round(val*10); @@ -395,8 +404,9 @@ The default cases are hard-coded. TODO: actually parse them The frac helper function is used for fraction formats (defined below). ```js>tmp/number.js - case "# ? / ?": ff = frac(val<0?-val:val, 10, true); return (val<0?"-":"") + ff[0] + " " + ff[1] + "/" + ff[2]; - case "# ?? / ??": ff = frac(val<0?-val:val, 100, true); return (val<0?"-":"") + ff[0] + " " + ff[1] + "/" + ff[2]; + case "# ? / ?": ff = frac(aval, 9, true); return sign + (ff[0]||"") + " " + (ff[1] === 0 ? " " : ff[1] + "/" + ff[2]); + case "# ?? / ??": ff = frac(aval, 99, true); return sign + (ff[0]||"") + " " + (ff[1] ? pad(ff[1],2," ") + "/" + rpad(ff[2],2," ") : " "); + case "# ??? / ???": ff = frac(aval, 999, true); return sign + (ff[0]||"") + " " + (ff[1] ? pad(ff[1],3," ") + "/" + rpad(ff[2],3," ") : " "); default: } throw new Error("unsupported format |" + fmt + "|"); @@ -512,8 +522,8 @@ Number blocks (following the general pattern `[0#?][0#?.,E+-%]*`) are grouped to ``` /* Numbers */ case '0': case '#': - var nn = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) nn += c; - out.push({t:'n', v:nn}); break; + o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) o += c; + out.push({t:'n', v:o}); break; ``` @@ -540,8 +550,17 @@ The open and close parens `()` also has special meaning (for negative numbers): case '(': case ')': out.push({t:(flen===1?'t':c),v:c}); ++i; break; ``` +The nonzero digits show up in fraction denominators: + +``` + case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + o = fmt[i]; while("0123456789".indexOf(fmt[++i]) > -1) o+=fmt[i]; + out.push({t:'D', v:o}); break; +``` + The default magic characters are listed in subsubsections 18.8.30-31 of ECMA376: + ``` case ' ': out.push({t:c,v:c}); ++i; break; default: @@ -569,7 +588,7 @@ The default magic characters are listed in subsubsections 18.8.30-31 of ECMA376: out[i].t = 't'; break; case 'n': case '(': var jj = i+1; - while(out[jj] && (out[jj].t == '?' || out[jj].t == ' ' || out[i].t == '(' && (out[jj].t == ')' || out[jj].t == 'n') || out[jj].t == 't' && (out[jj].v == '/' || out[jj].v == '$'))) { + while(out[jj] && ("? D".indexOf(out[jj].t) > -1 || out[i].t == '(' && (out[jj].t == ')' || out[jj].t == 'n') || out[jj].t == 't' && (out[jj].v == '/' || out[jj].v == '$' || (out[jj].v == ' ' && (out[jj+1]||{}).t == '?')))) { if(out[jj].v!==' ') out[i].v += ' ' + out[jj].v; delete out[jj]; ++jj; } @@ -670,7 +689,7 @@ function choose_fmt(fmt, v, o) { var l = fmt.length; switch(fmt.length) { case 1: fmt = [fmt[0], fmt[0], fmt[0], "@"]; break; - case 2: fmt = [fmt[0], fmt[1], fmt[0], "@"]; break; + case 2: fmt = [fmt[0], fmt[fmt[1] === "@"?0:1], fmt[0], "@"]; break; case 4: break; default: throw "cannot find right format for |" + fmt + "|"; } @@ -681,7 +700,7 @@ function choose_fmt(fmt, v, o) { var format = function format(fmt,v,o) { fixopts(o = (o||{})); if(fmt === 0) return general_fmt(v, o); - fmt = table_fmt[fmt]; + if(typeof fmt === 'number') fmt = table_fmt[fmt]; var f = choose_fmt(fmt, v, o); return eval_fmt(f[1], v, o, f[0]); }; @@ -705,24 +724,26 @@ SSF.format = format; The implementation is from [our frac library](https://github.com/SheetJS/frac/): ```js>tmp/frac.js -var frac = function(x, D, mixed) { - var n1 = Math.floor(x), d1 = 1; - var n2 = n1+1, d2 = 1; - if(x !== n1) while(d1 <= D && d2 <= D) { - var m = (n1 + n2) / (d1 + d2); - if(x === m) { - if(d1 + d2 <= D) { d1+=d2; n1+=n2; d2=D+1; } - else if(d1 > d2) d2=D+1; - else d1=D+1; - break; +var frac = function frac(x, D, mixed) { + var sgn = x < 0 ? -1 : 1; + var B = x * sgn; + var P_2 = 0, P_1 = 1, P = 0; + var Q_2 = 1, Q_1 = 0, Q = 0; + var A = B|0; + while(Q_1 < D) { + A = B|0; + P = A * P_1 + P_2; + Q = A * Q_1 + Q_2; + if((B - A) < 0.0000000001) break; + B = 1 / (B - A); + P_2 = P_1; P_1 = P; + Q_2 = Q_1; Q_1 = Q; } - else if(x < m) { n2 = n1+n2; d2 = d1+d2; } - else { n1 = n1+n2; d1 = d1+d2; } - } - if(d1 > D) { d1 = d2; n1 = n2; } - if(!mixed) return [0, n1, d1]; - var q = Math.floor(n1/d1); - return [q, n1 - q*d1, d1]; + if(Q > D) { Q = Q_1; P = P_1; } + if(Q > D) { Q = Q_2; P = P_2; } + if(!mixed) return [0, sgn * P, Q]; + var q = Math.floor(sgn * P/Q); + return [q, sgn*P - q*Q, Q]; }; ``` @@ -735,7 +756,8 @@ var make_ssf = function(SSF){ String.prototype.reverse=function(){return this.split("").reverse().join("");}; var _strrev = function(x) { return String(x).reverse(); }; function fill(c,l) { return new Array(l+1).join(c); } -function pad(v,d){var t=String(v);return t.length>=d?t:(fill(0,d-t.length)+t);} +function pad(v,d,c){var t=String(v);return t.length>=d?t:(fill(c||0,d-t.length)+t);} +function rpad(v,d,c){var t=String(v);return t.length>=d?t:(t+fill(c||0,d-t.length));} ``` ```js>tmp/zz_footer_n.js @@ -755,6 +777,7 @@ make_ssf(SSF); npm install cat tmp/{00_header,opts,consts,frac,general,date,number,main,zz_footer_n}.js > ssf_node.js cat tmp/{00_header,opts,consts,frac,general,date,number,main,zz_footer}.js > ssf.js + ``` ```json>.vocrc @@ -782,7 +805,7 @@ test: ```json>package.json { "name": "ssf", - "version": "0.3.1", + "version": "0.4.0", "author": "SheetJS", "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", "keywords": [ "format", "sprintf", "spreadsheet" ], @@ -834,6 +857,42 @@ describe('implied formats', function() { }); ``` +The general test driver tests the General format: + +```js>test/general.js +/* vim: set ts=2: */ +var SSF = require('../'); +var fs = require('fs'), assert = require('assert'); +var data = JSON.parse(fs.readFileSync('./test/general.json','utf8')); +var skip = []; +describe('General format', function() { + data.forEach(function(d) { + it(d[1]+" for "+d[0], skip.indexOf(d[1]) > -1 ? null : function(){ + assert.equal(SSF.format(d[1], d[0], {}), d[2]); + }); + }); +}); +``` + +The fraction test driver tests fractional formats: + +```js>test/fraction.js +/* vim: set ts=2: */ +var SSF = require('../'); +var fs = require('fs'), assert = require('assert'); +var data = JSON.parse(fs.readFileSync('./test/fraction.json','utf8')); +var skip = []; +describe('fractional formats', function() { + data.forEach(function(d) { + it(d[1]+" for "+d[0], skip.indexOf(d[1]) > -1 ? null : function(){ + var expected = d[2], actual = SSF.format(d[1], d[0], {}) + //var r = actual.match(/(-?)\d* *\d+\/\d+/); + assert.equal(actual, expected); + }); + }); +}); +``` + The old test driver was manual: ```js>tmp/test.njs diff --git a/ssf_node.js b/ssf_node.js index fdbd004..0c39d99 100644 --- a/ssf_node.js +++ b/ssf_node.js @@ -4,7 +4,8 @@ var make_ssf = function(SSF){ String.prototype.reverse=function(){return this.split("").reverse().join("");}; var _strrev = function(x) { return String(x).reverse(); }; function fill(c,l) { return new Array(l+1).join(c); } -function pad(v,d){var t=String(v);return t.length>=d?t:(fill(0,d-t.length)+t);} +function pad(v,d,c){var t=String(v);return t.length>=d?t:(fill(c||0,d-t.length)+t);} +function rpad(v,d,c){var t=String(v);return t.length>=d?t:(t+fill(c||0,d-t.length));} /* Options */ var opts_fmt = {}; function fixopts(o){for(var y in opts_fmt) if(o[y]===undefined) o[y]=opts_fmt[y];} @@ -64,24 +65,26 @@ var months = [ ['N', 'Nov', 'November'], ['D', 'Dec', 'December'] ]; -var frac = function(x, D, mixed) { - var n1 = Math.floor(x), d1 = 1; - var n2 = n1+1, d2 = 1; - if(x !== n1) while(d1 <= D && d2 <= D) { - var m = (n1 + n2) / (d1 + d2); - if(x === m) { - if(d1 + d2 <= D) { d1+=d2; n1+=n2; d2=D+1; } - else if(d1 > d2) d2=D+1; - else d1=D+1; - break; +var frac = function frac(x, D, mixed) { + var sgn = x < 0 ? -1 : 1; + var B = x * sgn; + var P_2 = 0, P_1 = 1, P = 0; + var Q_2 = 1, Q_1 = 0, Q = 0; + var A = B|0; + while(Q_1 < D) { + A = B|0; + P = A * P_1 + P_2; + Q = A * Q_1 + Q_2; + if((B - A) < 0.0000000001) break; + B = 1 / (B - A); + P_2 = P_1; P_1 = P; + Q_2 = Q_1; Q_1 = Q; } - else if(x < m) { n2 = n1+n2; d2 = d1+d2; } - else { n1 = n1+n2; d1 = d1+d2; } - } - if(d1 > D) { d1 = d2; n1 = n2; } - if(!mixed) return [0, n1, d1]; - var q = Math.floor(n1/d1); - return [q, n1 - q*d1, d1]; + if(Q > D) { Q = Q_1; P = P_1; } + if(Q > D) { Q = Q_2; P = P_2; } + if(!mixed) return [0, sgn * P, Q]; + var q = Math.floor(sgn * P/Q); + return [q, sgn*P - q*Q, Q]; }; var general_fmt = function(v) { if(typeof v === 'boolean') return v ? "TRUE" : "FALSE"; @@ -98,10 +101,9 @@ var general_fmt = function(v) { if(o.length > 11+(v<0?1:0)) o = v.toExponential(5); } else { - o = v.toFixed(11).replace(/(\.[0-9]*[1-9])0*$/,"$1") - if(o.length > 11 + (v<0?1:0)) o = v.toPrecision(6); + o = v.toFixed(11).replace(/(\.[0-9]*[1-9])0*$/,"$1"); + if(o.length > 11 + (v<0?1:0)) o = v.toPrecision(6); } - if(v==0.000000001) console.log(v, o); o = o.replace(/(\.[0-9]*[1-9])0+e/,"$1e").replace(/\.0*e/,"e"); return o.replace("e","E").replace(/\.0*$/,"").replace(/\.([0-9]*[^0])0*$/,".$1").replace(/(E[+-])([0-9])$/,"$1"+"0"+"$2"); } @@ -208,6 +210,11 @@ var write_num = function(type, fmt, val) { } if(fmt[0] === "$") return "$"+write_num(type,fmt.substr(fmt[1]==' '?2:1),val); var r, ff, aval = val < 0 ? -val : val, sign = val < 0 ? "-" : ""; + if((r = fmt.match(/# (\?+) \/ (\d+)/))) { + var den = Number(r[2]), rnd = Math.round(aval * den), base = Math.floor(rnd/den); + var myn = (rnd - base*den), myd = den; + return sign + (base?base:"") + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[2].length) : pad(myn,r[1].length," ") + "/" + pad(myd,r[2].length)); + } switch(fmt) { case "0": return Math.round(val); case "0.0": o = Math.round(val*10); @@ -219,8 +226,9 @@ var write_num = function(type, fmt, val) { case "#,##0": return sign + commaify(String(Math.round(aval))); case "#,##0.0": r = Math.round((val-Math.floor(val))*10); return val < 0 ? "-" + write_num(type, fmt, -val) : commaify(String(Math.floor(val))) + "." + r; case "#,##0.00": r = Math.round((val-Math.floor(val))*100); return val < 0 ? "-" + write_num(type, fmt, -val) : commaify(String(Math.floor(val))) + "." + (r < 10 ? "0"+r:r); - case "# ? / ?": ff = frac(val<0?-val:val, 10, true); return (val<0?"-":"") + ff[0] + " " + ff[1] + "/" + ff[2]; - case "# ?? / ??": ff = frac(val<0?-val:val, 100, true); return (val<0?"-":"") + ff[0] + " " + ff[1] + "/" + ff[2]; + case "# ? / ?": ff = frac(aval, 9, true); return sign + (ff[0]||"") + " " + (ff[1] === 0 ? " " : ff[1] + "/" + ff[2]); + case "# ?? / ??": ff = frac(aval, 99, true); return sign + (ff[0]||"") + " " + (ff[1] ? pad(ff[1],2," ") + "/" + rpad(ff[2],2," ") : " "); + case "# ??? / ???": ff = frac(aval, 999, true); return sign + (ff[0]||"") + " " + (ff[1] ? pad(ff[1],3," ") + "/" + rpad(ff[2],3," ") : " "); default: } throw new Error("unsupported format |" + fmt + "|"); @@ -279,13 +287,16 @@ function eval_fmt(fmt, v, opts, flen) { break; /* Numbers */ case '0': case '#': - var nn = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) nn += c; - out.push({t:'n', v:nn}); break; + o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1) o += c; + out.push({t:'n', v:o}); break; case '?': o = fmt[i]; while(fmt[++i] === c) o+=c; q={t:c, v:o}; out.push(q); lst = c; break; case '*': ++i; if(fmt[i] == ' ') ++i; break; // ** case '(': case ')': out.push({t:(flen===1?'t':c),v:c}); ++i; break; + case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': + o = fmt[i]; while("0123456789".indexOf(fmt[++i]) > -1) o+=fmt[i]; + out.push({t:'D', v:o}); break; case ' ': out.push({t:c,v:c}); ++i; break; default: if("$-+/():!^&'~{}<>=".indexOf(c) === -1) @@ -312,7 +323,7 @@ function eval_fmt(fmt, v, opts, flen) { out[i].t = 't'; break; case 'n': case '(': var jj = i+1; - while(out[jj] && (out[jj].t == '?' || out[jj].t == ' ' || out[i].t == '(' && (out[jj].t == ')' || out[jj].t == 'n') || out[jj].t == 't' && (out[jj].v == '/' || out[jj].v == '$'))) { + while(out[jj] && ("? D".indexOf(out[jj].t) > -1 || out[i].t == '(' && (out[jj].t == ')' || out[jj].t == 'n') || out[jj].t == 't' && (out[jj].v == '/' || out[jj].v == '$' || (out[jj].v == ' ' && (out[jj+1]||{}).t == '?')))) { if(out[jj].v!==' ') out[i].v += ' ' + out[jj].v; delete out[jj]; ++jj; } @@ -332,7 +343,7 @@ function choose_fmt(fmt, v, o) { var l = fmt.length; switch(fmt.length) { case 1: fmt = [fmt[0], fmt[0], fmt[0], "@"]; break; - case 2: fmt = [fmt[0], fmt[1], fmt[0], "@"]; break; + case 2: fmt = [fmt[0], fmt[fmt[1] === "@"?0:1], fmt[0], "@"]; break; case 4: break; default: throw "cannot find right format for |" + fmt + "|"; } @@ -343,7 +354,7 @@ function choose_fmt(fmt, v, o) { var format = function format(fmt,v,o) { fixopts(o = (o||{})); if(fmt === 0) return general_fmt(v, o); - fmt = table_fmt[fmt]; + if(typeof fmt === 'number') fmt = table_fmt[fmt]; var f = choose_fmt(fmt, v, o); return eval_fmt(f[1], v, o, f[0]); }; diff --git a/test/fraction.js b/test/fraction.js new file mode 100644 index 0000000..8df4dd5 --- /dev/null +++ b/test/fraction.js @@ -0,0 +1,14 @@ +/* vim: set ts=2: */ +var SSF = require('../'); +var fs = require('fs'), assert = require('assert'); +var data = JSON.parse(fs.readFileSync('./test/fraction.json','utf8')); +var skip = []; +describe('fractional formats', function() { + data.forEach(function(d) { + it(d[1]+" for "+d[0], skip.indexOf(d[1]) > -1 ? null : function(){ + var expected = d[2], actual = SSF.format(d[1], d[0], {}) + //var r = actual.match(/(-?)\d* *\d+\/\d+/); + assert.equal(actual, expected); + }); + }); +}); diff --git a/test/fraction.json b/test/fraction.json new file mode 100644 index 0000000..d48da3e --- /dev/null +++ b/test/fraction.json @@ -0,0 +1,107 @@ +[ + [1, "# ?/?", "1 "], + [-1.2, "# ?/?", "-1 1/5"], + [12.3, "# ?/?", "12 1/3"], + [-12.34, "# ?/?", "-12 1/3"], + [123.45, "# ?/?", "123 4/9"], + [-123.456, "# ?/?", "-123 1/2"], + [1234.567, "# ?/?", "1234 4/7"], + [-1234.5678, "# ?/?", "-1234 4/7"], + [12345.6789, "# ?/?", "12345 2/3"], + [-12345.67891, "# ?/?", "-12345 2/3"], + + [1, "# ??/??", "1 "], + [-1.2, "# ??/??", "-1 1/5 "], + [12.3, "# ??/??", "12 3/10"], + [-12.34, "# ??/??", "-12 17/50"], + [123.45, "# ??/??", "123 9/20"], + [-123.456, "# ??/??", "-123 26/57"], + [1234.567, "# ??/??", "1234 55/97"], + [-1234.5678, "# ??/??", "-1234 46/81"], + [12345.6789, "# ??/??", "12345 55/81"], + [-12345.67891, "# ??/??", "-12345 55/81"], + + [1, "# ???/???", "1 "], + [-1.2, "# ???/???", "-1 1/5 "], + [12.3, "# ???/???", "12 3/10 "], + [-12.34, "# ???/???", "-12 17/50 "], + [123.45, "# ???/???", "123 9/20 "], + [-123.456, "# ???/???", "-123 57/125"], + [1234.567, "# ???/???", "1234 55/97 "], + [-1234.5678, "# ???/???", "-1234 67/118"], + [12345.6789, "# ???/???", "12345 74/109"], + [-12345.67891, "# ???/???", "-12345 573/844"], + + + [1, "# ?/2", "1 "], + [-1.2, "# ?/2", "-1 "], + [12.3, "# ?/2", "12 1/2"], + [-12.34, "# ?/2", "-12 1/2"], + [123.45, "# ?/2", "123 1/2"], + [-123.456, "# ?/2", "-123 1/2"], + [1234.567, "# ?/2", "1234 1/2"], + [-1234.5678, "# ?/2", "-1234 1/2"], + [12345.6789, "# ?/2", "12345 1/2"], + [-12345.67891, "# ?/2", "-12345 1/2"], + + [1, "# ?/4", "1 "], + [-1.2, "# ?/4", "-1 1/4"], + [12.3, "# ?/4", "12 1/4"], + [-12.34, "# ?/4", "-12 1/4"], + [123.45, "# ?/4", "123 2/4"], + [-123.456, "# ?/4", "-123 2/4"], + [1234.567, "# ?/4", "1234 2/4"], + [-1234.5678, "# ?/4", "-1234 2/4"], + [12345.6789, "# ?/4", "12345 3/4"], + [-12345.67891, "# ?/4", "-12345 3/4"], + + [1, "# ?/8", "1 "], + [-1.2, "# ?/8", "-1 2/8"], + [12.3, "# ?/8", "12 2/8"], + [-12.34, "# ?/8", "-12 3/8"], + [123.45, "# ?/8", "123 4/8"], + [-123.456, "# ?/8", "-123 4/8"], + [1234.567, "# ?/8", "1234 5/8"], + [-1234.5678, "# ?/8", "-1234 5/8"], + [12345.6789, "# ?/8", "12345 5/8"], + [-12345.67891, "# ?/8", "-12345 5/8"], + + [1, "# ??/16", "1 "], + [-1.2, "# ??/16", "-1 3/16"], + [12.3, "# ??/16", "12 5/16"], + [-12.34, "# ??/16", "-12 5/16"], + [123.45, "# ??/16", "123 7/16"], + [-123.456, "# ??/16", "-123 7/16"], + [1234.567, "# ??/16", "1234 9/16"], + [-1234.5678, "# ??/16", "-1234 9/16"], + [12345.6789, "# ??/16", "12345 11/16"], + [-12345.67891, "# ??/16", "-12345 11/16"], + + [1, "# ?/10", "1 "], + [-1.2, "# ?/10", "-1 2/10"], + [12.3, "# ?/10", "12 3/10"], + [-12.34, "# ?/10", "-12 3/10"], + [123.45, "# ?/10", "123 5/10"], + [-123.456, "# ?/10", "-123 5/10"], + [1234.567, "# ?/10", "1234 6/10"], + [-1234.5678, "# ?/10", "-1234 6/10"], + [12345.6789, "# ?/10", "12345 7/10"], + [-12345.67891, "# ?/10", "-12345 7/10"], + + [1, "# ??/100", "1 "], + [-1.2, "# ??/100", "-1 20/100"], + [12.3, "# ??/100", "12 30/100"], + [-12.34, "# ??/100", "-12 34/100"], + [123.45, "# ??/100", "123 45/100"], + [-123.456, "# ??/100", "-123 46/100"], + [1234.567, "# ??/100", "1234 57/100"], + [-1234.5678, "# ??/100", "-1234 57/100"], + [12345.6789, "# ??/100", "12345 68/100"], + [-12345.67891, "# ??/100", "-12345 68/100"], + + [0.3, "# ?/?", " 2/7"], + [1.3, "# ?/?", "1 1/3"], + [2.3, "# ?/?", "2 2/7"], + + [0, "0", "0"] +] diff --git a/test/general.js b/test/general.js new file mode 100644 index 0000000..633526e --- /dev/null +++ b/test/general.js @@ -0,0 +1,12 @@ +/* vim: set ts=2: */ +var SSF = require('../'); +var fs = require('fs'), assert = require('assert'); +var data = JSON.parse(fs.readFileSync('./test/general.json','utf8')); +var skip = []; +describe('General format', function() { + data.forEach(function(d) { + it(d[1]+" for "+d[0], skip.indexOf(d[1]) > -1 ? null : function(){ + assert.equal(SSF.format(d[1], d[0], {}), d[2]); + }); + }); +}); diff --git a/test/general.json b/test/general.json new file mode 100644 index 0000000..e7794b7 --- /dev/null +++ b/test/general.json @@ -0,0 +1,516 @@ +[ + [1.234567E-14, 0, "1.23457E-14"], + [1.234567E-13, 0, "1.23457E-13"], + [1.234567E-12, 0, "1.23457E-12"], + [1.234567E-11, 0, "1.23457E-11"], + [1.234567E-10, 0, "1.23457E-10"], + [1.234567E-9, 0, "1.23457E-09"], + [1.234567E-8, 0, "1.23457E-08"], + [1.234567E-7, 0, "1.23457E-07"], + [1.234567E-6, 0, "1.23457E-06"], + [1.234567E-5, 0, "1.23457E-05"], + [1.234567E-4, 0, "0.000123457"], + [1.234567E-3, 0, "0.001234567"], + [1.234567E-2, 0, "0.01234567"], + [1.234567E-1, 0, "0.1234567"], + [1.234567E0, 0, "1.234567"], + [1.234567E1, 0, "12.34567"], + [1.234567E2, 0, "123.4567"], + [1.234567E3, 0, "1234.567"], + [1.234567E4, 0, "12345.67"], + [1.234567E5, 0, "123456.7"], + [1.234567E6, 0, "1234567"], + [1.234567E7, 0, "12345670"], + [1.234567E8, 0, "123456700"], + [1.234567E9, 0, "1234567000"], + [1.234567E10, 0, "12345670000"], + [1.234567E11, 0, "1.23457E+11"], + [1.234567E12, 0, "1.23457E+12"], + [1.234567E13, 0, "1.23457E+13"], + [1.234567E14, 0, "1.23457E+14"], + + [0.00000000000001, 0, "1E-14"], + [0.0000000000001, 0, "1E-13"], + [0.000000000001, 0, "1E-12"], + [0.00000000001, 0, "1E-11"], + [0.0000000001, 0, "1E-10"], + [0.000000001, 0, "0.000000001"], + [0.00000001, 0, "0.00000001"], + [0.0000001, 0, "0.0000001"], + [0.000001, 0, "0.000001"], + [0.00001, 0, "0.00001"], + [0.0001, 0, "0.0001"], + [0.001, 0, "0.001"], + [0.01, 0, "0.01"], + [0.1, 0, "0.1"], + [1, 0, "1"], + [10, 0, "10"], + [100, 0, "100"], + [1000, 0, "1000"], + [10000, 0, "10000"], + [100000, 0, "100000"], + [1000000, 0, "1000000"], + [10000000, 0, "10000000"], + [100000000, 0, "100000000"], + [1000000000, 0, "1000000000"], + [10000000000, 0, "10000000000"], + [100000000000, 0, "1E+11"], + [1000000000000, 0, "1E+12"], + [10000000000000, 0, "1E+13"], + [100000000000000, 0, "1E+14"], + + [0.000000000000012, 0, "1.2E-14"], + [0.00000000000012, 0, "1.2E-13"], + [0.0000000000012, 0, "1.2E-12"], + [0.000000000012, 0, "1.2E-11"], + [0.00000000012, 0, "1.2E-10"], + [0.0000000012, 0, "1.2E-09"], + [0.000000012, 0, "0.000000012"], + [0.00000012, 0, "0.00000012"], + [0.0000012, 0, "0.0000012"], + [0.000012, 0, "0.000012"], + [0.00012, 0, "0.00012"], + [0.0012, 0, "0.0012"], + [0.012, 0, "0.012"], + [0.12, 0, "0.12"], + [1.2, 0, "1.2"], + [12, 0, "12"], + [120, 0, "120"], + [1200, 0, "1200"], + [12000, 0, "12000"], + [120000, 0, "120000"], + [1200000, 0, "1200000"], + [12000000, 0, "12000000"], + [120000000, 0, "120000000"], + [1200000000, 0, "1200000000"], + [12000000000, 0, "12000000000"], + [120000000000, 0, "1.2E+11"], + [1200000000000, 0, "1.2E+12"], + [12000000000000, 0, "1.2E+13"], + [120000000000000, 0, "1.2E+14"], + + [0.0000000000000123, 0, "1.23E-14"], + [0.000000000000123, 0, "1.23E-13"], + [0.00000000000123, 0, "1.23E-12"], + [0.0000000000123, 0, "1.23E-11"], + [0.000000000123, 0, "1.23E-10"], + [0.00000000123, 0, "1.23E-09"], + [0.0000000123, 0, "1.23E-08"], + [0.000000123, 0, "0.000000123"], + [0.00000123, 0, "0.00000123"], + [0.0000123, 0, "0.0000123"], + [0.000123, 0, "0.000123"], + [0.00123, 0, "0.00123"], + [0.0123, 0, "0.0123"], + [0.123, 0, "0.123"], + [1.23, 0, "1.23"], + [12.3, 0, "12.3"], + [123, 0, "123"], + [1230, 0, "1230"], + [12300, 0, "12300"], + [123000, 0, "123000"], + [1230000, 0, "1230000"], + [12300000, 0, "12300000"], + [123000000, 0, "123000000"], + [1230000000, 0, "1230000000"], + [12300000000, 0, "12300000000"], + [123000000000, 0, "1.23E+11"], + [1230000000000, 0, "1.23E+12"], + [12300000000000, 0, "1.23E+13"], + [123000000000000, 0, "1.23E+14"], + + [0.00000000000001234, 0, "1.234E-14"], + [0.0000000000001234, 0, "1.234E-13"], + [0.000000000001234, 0, "1.234E-12"], + [0.00000000001234, 0, "1.234E-11"], + [0.0000000001234, 0, "1.234E-10"], + [0.000000001234, 0, "1.234E-09"], + [0.00000001234, 0, "1.234E-08"], + [0.0000001234, 0, "1.234E-07"], + [0.000001234, 0, "0.000001234"], + [0.00001234, 0, "0.00001234"], + [0.0001234, 0, "0.0001234"], + [0.001234, 0, "0.001234"], + [0.01234, 0, "0.01234"], + [0.1234, 0, "0.1234"], + [1.234, 0, "1.234"], + [12.34, 0, "12.34"], + [123.4, 0, "123.4"], + [1234, 0, "1234"], + [12340, 0, "12340"], + [123400, 0, "123400"], + [1234000, 0, "1234000"], + [12340000, 0, "12340000"], + [123400000, 0, "123400000"], + [1234000000, 0, "1234000000"], + [12340000000, 0, "12340000000"], + [123400000000, 0, "1.234E+11"], + [1234000000000, 0, "1.234E+12"], + [12340000000000, 0, "1.234E+13"], + [123400000000000, 0, "1.234E+14"], + + [0.000000000000012345, 0, "1.2345E-14"], + [0.00000000000012345, 0, "1.2345E-13"], + [0.0000000000012345, 0, "1.2345E-12"], + [0.000000000012345, 0, "1.2345E-11"], + [0.00000000012345, 0, "1.2345E-10"], + [0.0000000012345, 0, "1.2345E-09"], + [0.000000012345, 0, "1.2345E-08"], + [0.00000012345, 0, "1.2345E-07"], + [0.0000012345, 0, "1.2345E-06"], + [0.000012345, 0, "0.000012345"], + [0.00012345, 0, "0.00012345"], + [0.0012345, 0, "0.0012345"], + [0.012345, 0, "0.012345"], + [0.12345, 0, "0.12345"], + [1.2345, 0, "1.2345"], + [12.345, 0, "12.345"], + [123.45, 0, "123.45"], + [1234.5, 0, "1234.5"], + [12345, 0, "12345"], + [123450, 0, "123450"], + [1234500, 0, "1234500"], + [12345000, 0, "12345000"], + [123450000, 0, "123450000"], + [1234500000, 0, "1234500000"], + [12345000000, 0, "12345000000"], + [123450000000, 0, "1.2345E+11"], + [1234500000000, 0, "1.2345E+12"], + [12345000000000, 0, "1.2345E+13"], + [123450000000000, 0, "1.2345E+14"], + + [0.0000000000000123456, 0, "1.23456E-14"], + [0.000000000000123456, 0, "1.23456E-13"], + [0.00000000000123456, 0, "1.23456E-12"], + [0.0000000000123456, 0, "1.23456E-11"], + [0.000000000123456, 0, "1.23456E-10"], + [0.00000000123456, 0, "1.23456E-09"], + [0.0000000123456, 0, "1.23456E-08"], + [0.000000123456, 0, "1.23456E-07"], + [0.00000123456, 0, "1.23456E-06"], + [0.0000123456, 0, "1.23456E-05"], + [0.000123456, 0, "0.000123456"], + [0.00123456, 0, "0.00123456"], + [0.0123456, 0, "0.0123456"], + [0.123456, 0, "0.123456"], + [1.23456, 0, "1.23456"], + [12.3456, 0, "12.3456"], + [123.456, 0, "123.456"], + [1234.56, 0, "1234.56"], + [12345.6, 0, "12345.6"], + [123456, 0, "123456"], + [1234560, 0, "1234560"], + [12345600, 0, "12345600"], + [123456000, 0, "123456000"], + [1234560000, 0, "1234560000"], + [12345600000, 0, "12345600000"], + [123456000000, 0, "1.23456E+11"], + [1234560000000, 0, "1.23456E+12"], + [12345600000000, 0, "1.23456E+13"], + [123456000000000, 0, "1.23456E+14"], + + [0.00000000000001234567, 0, "1.23457E-14"], + [0.0000000000001234567, 0, "1.23457E-13"], + [0.000000000001234567, 0, "1.23457E-12"], + [0.00000000001234567, 0, "1.23457E-11"], + [0.0000000001234567, 0, "1.23457E-10"], + [0.000000001234567, 0, "1.23457E-09"], + [0.00000001234567, 0, "1.23457E-08"], + [0.0000001234567, 0, "1.23457E-07"], + [0.000001234567, 0, "1.23457E-06"], + [0.00001234567, 0, "1.23457E-05"], + [0.0001234567, 0, "0.000123457"], + [0.001234567, 0, "0.001234567"], + [0.01234567, 0, "0.01234567"], + [0.1234567, 0, "0.1234567"], + [1.234567, 0, "1.234567"], + [12.34567, 0, "12.34567"], + [123.4567, 0, "123.4567"], + [1234.567, 0, "1234.567"], + [12345.67, 0, "12345.67"], + [123456.7, 0, "123456.7"], + [1234567, 0, "1234567"], + [12345670, 0, "12345670"], + [123456700, 0, "123456700"], + [1234567000, 0, "1234567000"], + [12345670000, 0, "12345670000"], + [123456700000, 0, "1.23457E+11"], + [1234567000000, 0, "1.23457E+12"], + [12345670000000, 0, "1.23457E+13"], + [123456700000000, 0, "1.23457E+14"], + + [0.000000000000012345678, 0, "1.23457E-14"], + [0.00000000000012345678, 0, "1.23457E-13"], + [0.0000000000012345678, 0, "1.23457E-12"], + [0.000000000012345678, 0, "1.23457E-11"], + [0.00000000012345678, 0, "1.23457E-10"], + [0.0000000012345678, 0, "1.23457E-09"], + [0.000000012345678, 0, "1.23457E-08"], + [0.00000012345678, 0, "1.23457E-07"], + [0.0000012345678, 0, "1.23457E-06"], + [0.000012345678, 0, "1.23457E-05"], + [0.00012345678, 0, "0.000123457"], + [0.0012345678, 0, "0.001234568"], + [0.012345678, 0, "0.012345678"], + [0.12345678, 0, "0.12345678"], + [1.2345678, 0, "1.2345678"], + [12.345678, 0, "12.345678"], + [123.45678, 0, "123.45678"], + [1234.5678, 0, "1234.5678"], + [12345.678, 0, "12345.678"], + [123456.78, 0, "123456.78"], + [1234567.8, 0, "1234567.8"], + [12345678, 0, "12345678"], + [123456780, 0, "123456780"], + [1234567800, 0, "1234567800"], + [12345678000, 0, "12345678000"], + [123456780000, 0, "1.23457E+11"], + [1234567800000, 0, "1.23457E+12"], + [12345678000000, 0, "1.23457E+13"], + [123456780000000, 0, "1.23457E+14"], + + [0.0000000000000123456789, 0, "1.23457E-14"], + [0.000000000000123456789, 0, "1.23457E-13"], + [0.00000000000123456789, 0, "1.23457E-12"], + [0.0000000000123456789, 0, "1.23457E-11"], + [0.000000000123456789, 0, "1.23457E-10"], + [0.00000000123456789, 0, "1.23457E-09"], + [0.0000000123456789, 0, "1.23457E-08"], + [0.000000123456789, 0, "1.23457E-07"], + [0.00000123456789, 0, "1.23457E-06"], + [0.0000123456789, 0, "1.23457E-05"], + [0.000123456789, 0, "0.000123457"], + [0.00123456789, 0, "0.001234568"], + [0.0123456789, 0, "0.012345679"], + [0.123456789, 0, "0.123456789"], + [1.23456789, 0, "1.23456789"], + [12.3456789, 0, "12.3456789"], + [123.456789, 0, "123.456789"], + [1234.56789, 0, "1234.56789"], + [12345.6789, 0, "12345.6789"], + [123456.789, 0, "123456.789"], + [1234567.89, 0, "1234567.89"], + [12345678.9, 0, "12345678.9"], + [123456789, 0, "123456789"], + [1234567890, 0, "1234567890"], + [12345678900, 0, "12345678900"], + [123456789000, 0, "1.23457E+11"], + [1234567890000, 0, "1.23457E+12"], + [12345678900000, 0, "1.23457E+13"], + [123456789000000, 0, "1.23457E+14"], + + [0.00000000000001234567891, 0, "1.23457E-14"], + [0.0000000000001234567891, 0, "1.23457E-13"], + [0.000000000001234567891, 0, "1.23457E-12"], + [0.00000000001234567891, 0, "1.23457E-11"], + [0.0000000001234567891, 0, "1.23457E-10"], + [0.000000001234567891, 0, "1.23457E-09"], + [0.00000001234567891, 0, "1.23457E-08"], + [0.0000001234567891, 0, "1.23457E-07"], + [0.000001234567891, 0, "1.23457E-06"], + [0.00001234567891, 0, "1.23457E-05"], + [0.0001234567891, 0, "0.000123457"], + [0.001234567891, 0, "0.001234568"], + [0.01234567891, 0, "0.012345679"], + [0.1234567891, 0, "0.123456789"], + [1.234567891, 0, "1.234567891"], + [12.34567891, 0, "12.34567891"], + [123.4567891, 0, "123.4567891"], + [1234.567891, 0, "1234.567891"], + [12345.67891, 0, "12345.67891"], + [123456.7891, 0, "123456.7891"], + [1234567.891, 0, "1234567.891"], + [12345678.91, 0, "12345678.91"], + [123456789.1, 0, "123456789.1"], + [1234567891, 0, "1234567891"], + [12345678910, 0, "12345678910"], + [123456789100, 0, "1.23457E+11"], + [1234567891000, 0, "1.23457E+12"], + [12345678910000, 0, "1.23457E+13"], + [123456789100000, 0, "1.23457E+14"], + + [0.000000000000012345678912, 0, "1.23457E-14"], + [0.00000000000012345678912, 0, "1.23457E-13"], + [0.0000000000012345678912, 0, "1.23457E-12"], + [0.000000000012345678912, 0, "1.23457E-11"], + [0.00000000012345678912, 0, "1.23457E-10"], + [0.0000000012345678912, 0, "1.23457E-09"], + [0.000000012345678912, 0, "1.23457E-08"], + [0.00000012345678912, 0, "1.23457E-07"], + [0.0000012345678912, 0, "1.23457E-06"], + [0.000012345678912, 0, "1.23457E-05"], + [0.00012345678912, 0, "0.000123457"], + [0.0012345678912, 0, "0.001234568"], + [0.012345678912, 0, "0.012345679"], + [0.12345678912, 0, "0.123456789"], + [1.2345678912, 0, "1.234567891"], + [12.345678912, 0, "12.34567891"], + [123.45678912, 0, "123.4567891"], + [1234.5678912, 0, "1234.567891"], + [12345.678912, 0, "12345.67891"], + [123456.78912, 0, "123456.7891"], + [1234567.8912, 0, "1234567.891"], + [12345678.912, 0, "12345678.91"], + [123456789.12, 0, "123456789.1"], + [1234567891.2, 0, "1234567891"], + [12345678912, 0, "12345678912"], + [123456789120, 0, "1.23457E+11"], + [1234567891200, 0, "1.23457E+12"], + [12345678912000, 0, "1.23457E+13"], + [123456789120000, 0, "1.23457E+14"], + + [0.0000000000000123456789123, 0, "1.23457E-14"], + [0.000000000000123456789123, 0, "1.23457E-13"], + [0.00000000000123456789123, 0, "1.23457E-12"], + [0.0000000000123456789123, 0, "1.23457E-11"], + [0.000000000123456789123, 0, "1.23457E-10"], + [0.00000000123456789123, 0, "1.23457E-09"], + [0.0000000123456789123, 0, "1.23457E-08"], + [0.000000123456789123, 0, "1.23457E-07"], + [0.00000123456789123, 0, "1.23457E-06"], + [0.0000123456789123, 0, "1.23457E-05"], + [0.000123456789123, 0, "0.000123457"], + [0.00123456789123, 0, "0.001234568"], + [0.0123456789123, 0, "0.012345679"], + [0.123456789123, 0, "0.123456789"], + [1.23456789123, 0, "1.234567891"], + [12.3456789123, 0, "12.34567891"], + [123.456789123, 0, "123.4567891"], + [1234.56789123, 0, "1234.567891"], + [12345.6789123, 0, "12345.67891"], + [123456.789123, 0, "123456.7891"], + [1234567.89123, 0, "1234567.891"], + [12345678.9123, 0, "12345678.91"], + [123456789.123, 0, "123456789.1"], + [1234567891.23, 0, "1234567891"], + [12345678912.3, 0, "12345678912"], + [123456789123, 0, "1.23457E+11"], + [1234567891230, 0, "1.23457E+12"], + [12345678912300, 0, "1.23457E+13"], + [123456789123000, 0, "1.23457E+14"], + + [0.00000000000001234567891234, 0, "1.23457E-14"], + [0.0000000000001234567891234, 0, "1.23457E-13"], + [0.000000000001234567891234, 0, "1.23457E-12"], + [0.00000000001234567891234, 0, "1.23457E-11"], + [0.0000000001234567891234, 0, "1.23457E-10"], + [0.000000001234567891234, 0, "1.23457E-09"], + [0.00000001234567891234, 0, "1.23457E-08"], + [0.0000001234567891234, 0, "1.23457E-07"], + [0.000001234567891234, 0, "1.23457E-06"], + [0.00001234567891234, 0, "1.23457E-05"], + [0.0001234567891234, 0, "0.000123457"], + [0.001234567891234, 0, "0.001234568"], + [0.01234567891234, 0, "0.012345679"], + [0.1234567891234, 0, "0.123456789"], + [1.234567891234, 0, "1.234567891"], + [12.34567891234, 0, "12.34567891"], + [123.4567891234, 0, "123.4567891"], + [1234.567891234, 0, "1234.567891"], + [12345.67891234, 0, "12345.67891"], + [123456.7891234, 0, "123456.7891"], + [1234567.891234, 0, "1234567.891"], + [12345678.91234, 0, "12345678.91"], + [123456789.1234, 0, "123456789.1"], + [1234567891.234, 0, "1234567891"], + [12345678912.34, 0, "12345678912"], + [123456789123.4, 0, "1.23457E+11"], + [1234567891234, 0, "1.23457E+12"], + [12345678912340, 0, "1.23457E+13"], + [123456789123400, 0, "1.23457E+14"], + + [0.000000000000012345678912345, 0, "1.23457E-14"], + [0.00000000000012345678912345, 0, "1.23457E-13"], + [0.0000000000012345678912345, 0, "1.23457E-12"], + [0.000000000012345678912345, 0, "1.23457E-11"], + [0.00000000012345678912345, 0, "1.23457E-10"], + [0.0000000012345678912345, 0, "1.23457E-09"], + [0.000000012345678912345, 0, "1.23457E-08"], + [0.00000012345678912345, 0, "1.23457E-07"], + [0.0000012345678912345, 0, "1.23457E-06"], + [0.000012345678912345, 0, "1.23457E-05"], + [0.00012345678912345, 0, "0.000123457"], + [0.0012345678912345, 0, "0.001234568"], + [0.012345678912345, 0, "0.012345679"], + [0.12345678912345, 0, "0.123456789"], + [1.2345678912345, 0, "1.234567891"], + [12.345678912345, 0, "12.34567891"], + [123.45678912345, 0, "123.4567891"], + [1234.5678912345, 0, "1234.567891"], + [12345.678912345, 0, "12345.67891"], + [123456.78912345, 0, "123456.7891"], + [1234567.8912345, 0, "1234567.891"], + [12345678.912345, 0, "12345678.91"], + [123456789.12345, 0, "123456789.1"], + [1234567891.2345, 0, "1234567891"], + [12345678912.345, 0, "12345678912"], + [123456789123.45, 0, "1.23457E+11"], + [1234567891234.5, 0, "1.23457E+12"], + [12345678912345, 0, "1.23457E+13"], + [123456789123450, 0, "1.23457E+14"], + + [0.0000000000000123456789123456, 0, "1.23457E-14"], + [0.000000000000123456789123456, 0, "1.23457E-13"], + [0.00000000000123456789123456, 0, "1.23457E-12"], + [0.0000000000123456789123456, 0, "1.23457E-11"], + [0.000000000123456789123456, 0, "1.23457E-10"], + [0.00000000123456789123456, 0, "1.23457E-09"], + [0.0000000123456789123456, 0, "1.23457E-08"], + [0.000000123456789123456, 0, "1.23457E-07"], + [0.00000123456789123456, 0, "1.23457E-06"], + [0.0000123456789123456, 0, "1.23457E-05"], + [0.000123456789123456, 0, "0.000123457"], + [0.00123456789123456, 0, "0.001234568"], + [0.0123456789123456, 0, "0.012345679"], + [0.123456789123456, 0, "0.123456789"], + [1.23456789123456, 0, "1.234567891"], + [12.3456789123456, 0, "12.34567891"], + [123.456789123456, 0, "123.4567891"], + [1234.56789123456, 0, "1234.567891"], + [12345.6789123456, 0, "12345.67891"], + [123456.789123456, 0, "123456.7891"], + [1234567.89123456, 0, "1234567.891"], + [12345678.9123456, 0, "12345678.91"], + [123456789.123456, 0, "123456789.1"], + [1234567891.23456, 0, "1234567891"], + [12345678912.3456, 0, "12345678912"], + [123456789123.456, 0, "1.23457E+11"], + [1234567891234.56, 0, "1.23457E+12"], + [12345678912345.6, 0, "1.23457E+13"], + [123456789123456, 0, "1.23457E+14"], + + [-0.00000000000001234567, 0, "-1.23457E-14"], + [-0.0000000000001234567, 0, "-1.23457E-13"], + [-0.000000000001234567, 0, "-1.23457E-12"], + [-0.00000000001234567, 0, "-1.23457E-11"], + [-0.0000000001234567, 0, "-1.23457E-10"], + [-0.000000001234567, 0, "-1.23457E-09"], + [-0.00000001234567, 0, "-1.23457E-08"], + [-0.0000001234567, 0, "-1.23457E-07"], + [-0.000001234567, 0, "-1.23457E-06"], + [-0.00001234567, 0, "-1.23457E-05"], + [-0.0001234567, 0, "-0.000123457"], + [-0.001234567, 0, "-0.001234567"], + [-0.01234567, 0, "-0.01234567"], + [-0.1234567, 0, "-0.1234567"], + [-1.234567, 0, "-1.234567"], + [-12.34567, 0, "-12.34567"], + [-123.4567, 0, "-123.4567"], + [-1234.567, 0, "-1234.567"], + [-12345.67, 0, "-12345.67"], + [-123456.7, 0, "-123456.7"], + [-1234567, 0, "-1234567"], + [-12345670, 0, "-12345670"], + [-123456700, 0, "-123456700"], + [-1234567000, 0, "-1234567000"], + [-12345670000, 0, "-12345670000"], + [-123456700000, 0, "-1.23457E+11"], + [-1234567000000, 0, "-1.23457E+12"], + [-12345670000000, 0, "-1.23457E+13"], + [-123456700000000, 0, "-1.23457E+14"], + + [true, 0, "TRUE"], + [false, 0, "FALSE"], + + ["sheetjs", 0, "sheetjs"] +] diff --git a/test/implied.json b/test/implied.json index 5bc4cd4..d4d63f8 100644 --- a/test/implied.json +++ b/test/implied.json @@ -57,519 +57,6 @@ [-12345.6789, 48, "-12.3E+3"], [-12345.6789, 49, "-12345.6789"], - [1.234567E-14, 0, "1.23457E-14"], - [1.234567E-13, 0, "1.23457E-13"], - [1.234567E-12, 0, "1.23457E-12"], - [1.234567E-11, 0, "1.23457E-11"], - [1.234567E-10, 0, "1.23457E-10"], - [1.234567E-9, 0, "1.23457E-09"], - [1.234567E-8, 0, "1.23457E-08"], - [1.234567E-7, 0, "1.23457E-07"], - [1.234567E-6, 0, "1.23457E-06"], - [1.234567E-5, 0, "1.23457E-05"], - [1.234567E-4, 0, "0.000123457"], - [1.234567E-3, 0, "0.001234567"], - [1.234567E-2, 0, "0.01234567"], - [1.234567E-1, 0, "0.1234567"], - [1.234567E0, 0, "1.234567"], - [1.234567E1, 0, "12.34567"], - [1.234567E2, 0, "123.4567"], - [1.234567E3, 0, "1234.567"], - [1.234567E4, 0, "12345.67"], - [1.234567E5, 0, "123456.7"], - [1.234567E6, 0, "1234567"], - [1.234567E7, 0, "12345670"], - [1.234567E8, 0, "123456700"], - [1.234567E9, 0, "1234567000"], - [1.234567E10, 0, "12345670000"], - [1.234567E11, 0, "1.23457E+11"], - [1.234567E12, 0, "1.23457E+12"], - [1.234567E13, 0, "1.23457E+13"], - [1.234567E14, 0, "1.23457E+14"], - - [0.00000000000001, 0, "1E-14"], - [0.0000000000001, 0, "1E-13"], - [0.000000000001, 0, "1E-12"], - [0.00000000001, 0, "1E-11"], - [0.0000000001, 0, "1E-10"], - [0.000000001, 0, "0.000000001"], - [0.00000001, 0, "0.00000001"], - [0.0000001, 0, "0.0000001"], - [0.000001, 0, "0.000001"], - [0.00001, 0, "0.00001"], - [0.0001, 0, "0.0001"], - [0.001, 0, "0.001"], - [0.01, 0, "0.01"], - [0.1, 0, "0.1"], - [1, 0, "1"], - [10, 0, "10"], - [100, 0, "100"], - [1000, 0, "1000"], - [10000, 0, "10000"], - [100000, 0, "100000"], - [1000000, 0, "1000000"], - [10000000, 0, "10000000"], - [100000000, 0, "100000000"], - [1000000000, 0, "1000000000"], - [10000000000, 0, "10000000000"], - [100000000000, 0, "1E+11"], - [1000000000000, 0, "1E+12"], - [10000000000000, 0, "1E+13"], - [100000000000000, 0, "1E+14"], - - [0.000000000000012, 0, "1.2E-14"], - [0.00000000000012, 0, "1.2E-13"], - [0.0000000000012, 0, "1.2E-12"], - [0.000000000012, 0, "1.2E-11"], - [0.00000000012, 0, "1.2E-10"], - [0.0000000012, 0, "1.2E-09"], - [0.000000012, 0, "0.000000012"], - [0.00000012, 0, "0.00000012"], - [0.0000012, 0, "0.0000012"], - [0.000012, 0, "0.000012"], - [0.00012, 0, "0.00012"], - [0.0012, 0, "0.0012"], - [0.012, 0, "0.012"], - [0.12, 0, "0.12"], - [1.2, 0, "1.2"], - [12, 0, "12"], - [120, 0, "120"], - [1200, 0, "1200"], - [12000, 0, "12000"], - [120000, 0, "120000"], - [1200000, 0, "1200000"], - [12000000, 0, "12000000"], - [120000000, 0, "120000000"], - [1200000000, 0, "1200000000"], - [12000000000, 0, "12000000000"], - [120000000000, 0, "1.2E+11"], - [1200000000000, 0, "1.2E+12"], - [12000000000000, 0, "1.2E+13"], - [120000000000000, 0, "1.2E+14"], - - [0.0000000000000123, 0, "1.23E-14"], - [0.000000000000123, 0, "1.23E-13"], - [0.00000000000123, 0, "1.23E-12"], - [0.0000000000123, 0, "1.23E-11"], - [0.000000000123, 0, "1.23E-10"], - [0.00000000123, 0, "1.23E-09"], - [0.0000000123, 0, "1.23E-08"], - [0.000000123, 0, "0.000000123"], - [0.00000123, 0, "0.00000123"], - [0.0000123, 0, "0.0000123"], - [0.000123, 0, "0.000123"], - [0.00123, 0, "0.00123"], - [0.0123, 0, "0.0123"], - [0.123, 0, "0.123"], - [1.23, 0, "1.23"], - [12.3, 0, "12.3"], - [123, 0, "123"], - [1230, 0, "1230"], - [12300, 0, "12300"], - [123000, 0, "123000"], - [1230000, 0, "1230000"], - [12300000, 0, "12300000"], - [123000000, 0, "123000000"], - [1230000000, 0, "1230000000"], - [12300000000, 0, "12300000000"], - [123000000000, 0, "1.23E+11"], - [1230000000000, 0, "1.23E+12"], - [12300000000000, 0, "1.23E+13"], - [123000000000000, 0, "1.23E+14"], - - [0.00000000000001234, 0, "1.234E-14"], - [0.0000000000001234, 0, "1.234E-13"], - [0.000000000001234, 0, "1.234E-12"], - [0.00000000001234, 0, "1.234E-11"], - [0.0000000001234, 0, "1.234E-10"], - [0.000000001234, 0, "1.234E-09"], - [0.00000001234, 0, "1.234E-08"], - [0.0000001234, 0, "1.234E-07"], - [0.000001234, 0, "0.000001234"], - [0.00001234, 0, "0.00001234"], - [0.0001234, 0, "0.0001234"], - [0.001234, 0, "0.001234"], - [0.01234, 0, "0.01234"], - [0.1234, 0, "0.1234"], - [1.234, 0, "1.234"], - [12.34, 0, "12.34"], - [123.4, 0, "123.4"], - [1234, 0, "1234"], - [12340, 0, "12340"], - [123400, 0, "123400"], - [1234000, 0, "1234000"], - [12340000, 0, "12340000"], - [123400000, 0, "123400000"], - [1234000000, 0, "1234000000"], - [12340000000, 0, "12340000000"], - [123400000000, 0, "1.234E+11"], - [1234000000000, 0, "1.234E+12"], - [12340000000000, 0, "1.234E+13"], - [123400000000000, 0, "1.234E+14"], - - [0.000000000000012345, 0, "1.2345E-14"], - [0.00000000000012345, 0, "1.2345E-13"], - [0.0000000000012345, 0, "1.2345E-12"], - [0.000000000012345, 0, "1.2345E-11"], - [0.00000000012345, 0, "1.2345E-10"], - [0.0000000012345, 0, "1.2345E-09"], - [0.000000012345, 0, "1.2345E-08"], - [0.00000012345, 0, "1.2345E-07"], - [0.0000012345, 0, "1.2345E-06"], - [0.000012345, 0, "0.000012345"], - [0.00012345, 0, "0.00012345"], - [0.0012345, 0, "0.0012345"], - [0.012345, 0, "0.012345"], - [0.12345, 0, "0.12345"], - [1.2345, 0, "1.2345"], - [12.345, 0, "12.345"], - [123.45, 0, "123.45"], - [1234.5, 0, "1234.5"], - [12345, 0, "12345"], - [123450, 0, "123450"], - [1234500, 0, "1234500"], - [12345000, 0, "12345000"], - [123450000, 0, "123450000"], - [1234500000, 0, "1234500000"], - [12345000000, 0, "12345000000"], - [123450000000, 0, "1.2345E+11"], - [1234500000000, 0, "1.2345E+12"], - [12345000000000, 0, "1.2345E+13"], - [123450000000000, 0, "1.2345E+14"], - - [0.0000000000000123456, 0, "1.23456E-14"], - [0.000000000000123456, 0, "1.23456E-13"], - [0.00000000000123456, 0, "1.23456E-12"], - [0.0000000000123456, 0, "1.23456E-11"], - [0.000000000123456, 0, "1.23456E-10"], - [0.00000000123456, 0, "1.23456E-09"], - [0.0000000123456, 0, "1.23456E-08"], - [0.000000123456, 0, "1.23456E-07"], - [0.00000123456, 0, "1.23456E-06"], - [0.0000123456, 0, "1.23456E-05"], - [0.000123456, 0, "0.000123456"], - [0.00123456, 0, "0.00123456"], - [0.0123456, 0, "0.0123456"], - [0.123456, 0, "0.123456"], - [1.23456, 0, "1.23456"], - [12.3456, 0, "12.3456"], - [123.456, 0, "123.456"], - [1234.56, 0, "1234.56"], - [12345.6, 0, "12345.6"], - [123456, 0, "123456"], - [1234560, 0, "1234560"], - [12345600, 0, "12345600"], - [123456000, 0, "123456000"], - [1234560000, 0, "1234560000"], - [12345600000, 0, "12345600000"], - [123456000000, 0, "1.23456E+11"], - [1234560000000, 0, "1.23456E+12"], - [12345600000000, 0, "1.23456E+13"], - [123456000000000, 0, "1.23456E+14"], - - [0.00000000000001234567, 0, "1.23457E-14"], - [0.0000000000001234567, 0, "1.23457E-13"], - [0.000000000001234567, 0, "1.23457E-12"], - [0.00000000001234567, 0, "1.23457E-11"], - [0.0000000001234567, 0, "1.23457E-10"], - [0.000000001234567, 0, "1.23457E-09"], - [0.00000001234567, 0, "1.23457E-08"], - [0.0000001234567, 0, "1.23457E-07"], - [0.000001234567, 0, "1.23457E-06"], - [0.00001234567, 0, "1.23457E-05"], - [0.0001234567, 0, "0.000123457"], - [0.001234567, 0, "0.001234567"], - [0.01234567, 0, "0.01234567"], - [0.1234567, 0, "0.1234567"], - [1.234567, 0, "1.234567"], - [12.34567, 0, "12.34567"], - [123.4567, 0, "123.4567"], - [1234.567, 0, "1234.567"], - [12345.67, 0, "12345.67"], - [123456.7, 0, "123456.7"], - [1234567, 0, "1234567"], - [12345670, 0, "12345670"], - [123456700, 0, "123456700"], - [1234567000, 0, "1234567000"], - [12345670000, 0, "12345670000"], - [123456700000, 0, "1.23457E+11"], - [1234567000000, 0, "1.23457E+12"], - [12345670000000, 0, "1.23457E+13"], - [123456700000000, 0, "1.23457E+14"], - - [0.000000000000012345678, 0, "1.23457E-14"], - [0.00000000000012345678, 0, "1.23457E-13"], - [0.0000000000012345678, 0, "1.23457E-12"], - [0.000000000012345678, 0, "1.23457E-11"], - [0.00000000012345678, 0, "1.23457E-10"], - [0.0000000012345678, 0, "1.23457E-09"], - [0.000000012345678, 0, "1.23457E-08"], - [0.00000012345678, 0, "1.23457E-07"], - [0.0000012345678, 0, "1.23457E-06"], - [0.000012345678, 0, "1.23457E-05"], - [0.00012345678, 0, "0.000123457"], - [0.0012345678, 0, "0.001234568"], - [0.012345678, 0, "0.012345678"], - [0.12345678, 0, "0.12345678"], - [1.2345678, 0, "1.2345678"], - [12.345678, 0, "12.345678"], - [123.45678, 0, "123.45678"], - [1234.5678, 0, "1234.5678"], - [12345.678, 0, "12345.678"], - [123456.78, 0, "123456.78"], - [1234567.8, 0, "1234567.8"], - [12345678, 0, "12345678"], - [123456780, 0, "123456780"], - [1234567800, 0, "1234567800"], - [12345678000, 0, "12345678000"], - [123456780000, 0, "1.23457E+11"], - [1234567800000, 0, "1.23457E+12"], - [12345678000000, 0, "1.23457E+13"], - [123456780000000, 0, "1.23457E+14"], - - [0.0000000000000123456789, 0, "1.23457E-14"], - [0.000000000000123456789, 0, "1.23457E-13"], - [0.00000000000123456789, 0, "1.23457E-12"], - [0.0000000000123456789, 0, "1.23457E-11"], - [0.000000000123456789, 0, "1.23457E-10"], - [0.00000000123456789, 0, "1.23457E-09"], - [0.0000000123456789, 0, "1.23457E-08"], - [0.000000123456789, 0, "1.23457E-07"], - [0.00000123456789, 0, "1.23457E-06"], - [0.0000123456789, 0, "1.23457E-05"], - [0.000123456789, 0, "0.000123457"], - [0.00123456789, 0, "0.001234568"], - [0.0123456789, 0, "0.012345679"], - [0.123456789, 0, "0.123456789"], - [1.23456789, 0, "1.23456789"], - [12.3456789, 0, "12.3456789"], - [123.456789, 0, "123.456789"], - [1234.56789, 0, "1234.56789"], - [12345.6789, 0, "12345.6789"], - [123456.789, 0, "123456.789"], - [1234567.89, 0, "1234567.89"], - [12345678.9, 0, "12345678.9"], - [123456789, 0, "123456789"], - [1234567890, 0, "1234567890"], - [12345678900, 0, "12345678900"], - [123456789000, 0, "1.23457E+11"], - [1234567890000, 0, "1.23457E+12"], - [12345678900000, 0, "1.23457E+13"], - [123456789000000, 0, "1.23457E+14"], - - [0.00000000000001234567891, 0, "1.23457E-14"], - [0.0000000000001234567891, 0, "1.23457E-13"], - [0.000000000001234567891, 0, "1.23457E-12"], - [0.00000000001234567891, 0, "1.23457E-11"], - [0.0000000001234567891, 0, "1.23457E-10"], - [0.000000001234567891, 0, "1.23457E-09"], - [0.00000001234567891, 0, "1.23457E-08"], - [0.0000001234567891, 0, "1.23457E-07"], - [0.000001234567891, 0, "1.23457E-06"], - [0.00001234567891, 0, "1.23457E-05"], - [0.0001234567891, 0, "0.000123457"], - [0.001234567891, 0, "0.001234568"], - [0.01234567891, 0, "0.012345679"], - [0.1234567891, 0, "0.123456789"], - [1.234567891, 0, "1.234567891"], - [12.34567891, 0, "12.34567891"], - [123.4567891, 0, "123.4567891"], - [1234.567891, 0, "1234.567891"], - [12345.67891, 0, "12345.67891"], - [123456.7891, 0, "123456.7891"], - [1234567.891, 0, "1234567.891"], - [12345678.91, 0, "12345678.91"], - [123456789.1, 0, "123456789.1"], - [1234567891, 0, "1234567891"], - [12345678910, 0, "12345678910"], - [123456789100, 0, "1.23457E+11"], - [1234567891000, 0, "1.23457E+12"], - [12345678910000, 0, "1.23457E+13"], - [123456789100000, 0, "1.23457E+14"], - - [0.000000000000012345678912, 0, "1.23457E-14"], - [0.00000000000012345678912, 0, "1.23457E-13"], - [0.0000000000012345678912, 0, "1.23457E-12"], - [0.000000000012345678912, 0, "1.23457E-11"], - [0.00000000012345678912, 0, "1.23457E-10"], - [0.0000000012345678912, 0, "1.23457E-09"], - [0.000000012345678912, 0, "1.23457E-08"], - [0.00000012345678912, 0, "1.23457E-07"], - [0.0000012345678912, 0, "1.23457E-06"], - [0.000012345678912, 0, "1.23457E-05"], - [0.00012345678912, 0, "0.000123457"], - [0.0012345678912, 0, "0.001234568"], - [0.012345678912, 0, "0.012345679"], - [0.12345678912, 0, "0.123456789"], - [1.2345678912, 0, "1.234567891"], - [12.345678912, 0, "12.34567891"], - [123.45678912, 0, "123.4567891"], - [1234.5678912, 0, "1234.567891"], - [12345.678912, 0, "12345.67891"], - [123456.78912, 0, "123456.7891"], - [1234567.8912, 0, "1234567.891"], - [12345678.912, 0, "12345678.91"], - [123456789.12, 0, "123456789.1"], - [1234567891.2, 0, "1234567891"], - [12345678912, 0, "12345678912"], - [123456789120, 0, "1.23457E+11"], - [1234567891200, 0, "1.23457E+12"], - [12345678912000, 0, "1.23457E+13"], - [123456789120000, 0, "1.23457E+14"], - - [0.0000000000000123456789123, 0, "1.23457E-14"], - [0.000000000000123456789123, 0, "1.23457E-13"], - [0.00000000000123456789123, 0, "1.23457E-12"], - [0.0000000000123456789123, 0, "1.23457E-11"], - [0.000000000123456789123, 0, "1.23457E-10"], - [0.00000000123456789123, 0, "1.23457E-09"], - [0.0000000123456789123, 0, "1.23457E-08"], - [0.000000123456789123, 0, "1.23457E-07"], - [0.00000123456789123, 0, "1.23457E-06"], - [0.0000123456789123, 0, "1.23457E-05"], - [0.000123456789123, 0, "0.000123457"], - [0.00123456789123, 0, "0.001234568"], - [0.0123456789123, 0, "0.012345679"], - [0.123456789123, 0, "0.123456789"], - [1.23456789123, 0, "1.234567891"], - [12.3456789123, 0, "12.34567891"], - [123.456789123, 0, "123.4567891"], - [1234.56789123, 0, "1234.567891"], - [12345.6789123, 0, "12345.67891"], - [123456.789123, 0, "123456.7891"], - [1234567.89123, 0, "1234567.891"], - [12345678.9123, 0, "12345678.91"], - [123456789.123, 0, "123456789.1"], - [1234567891.23, 0, "1234567891"], - [12345678912.3, 0, "12345678912"], - [123456789123, 0, "1.23457E+11"], - [1234567891230, 0, "1.23457E+12"], - [12345678912300, 0, "1.23457E+13"], - [123456789123000, 0, "1.23457E+14"], - - [0.00000000000001234567891234, 0, "1.23457E-14"], - [0.0000000000001234567891234, 0, "1.23457E-13"], - [0.000000000001234567891234, 0, "1.23457E-12"], - [0.00000000001234567891234, 0, "1.23457E-11"], - [0.0000000001234567891234, 0, "1.23457E-10"], - [0.000000001234567891234, 0, "1.23457E-09"], - [0.00000001234567891234, 0, "1.23457E-08"], - [0.0000001234567891234, 0, "1.23457E-07"], - [0.000001234567891234, 0, "1.23457E-06"], - [0.00001234567891234, 0, "1.23457E-05"], - [0.0001234567891234, 0, "0.000123457"], - [0.001234567891234, 0, "0.001234568"], - [0.01234567891234, 0, "0.012345679"], - [0.1234567891234, 0, "0.123456789"], - [1.234567891234, 0, "1.234567891"], - [12.34567891234, 0, "12.34567891"], - [123.4567891234, 0, "123.4567891"], - [1234.567891234, 0, "1234.567891"], - [12345.67891234, 0, "12345.67891"], - [123456.7891234, 0, "123456.7891"], - [1234567.891234, 0, "1234567.891"], - [12345678.91234, 0, "12345678.91"], - [123456789.1234, 0, "123456789.1"], - [1234567891.234, 0, "1234567891"], - [12345678912.34, 0, "12345678912"], - [123456789123.4, 0, "1.23457E+11"], - [1234567891234, 0, "1.23457E+12"], - [12345678912340, 0, "1.23457E+13"], - [123456789123400, 0, "1.23457E+14"], - - [0.000000000000012345678912345, 0, "1.23457E-14"], - [0.00000000000012345678912345, 0, "1.23457E-13"], - [0.0000000000012345678912345, 0, "1.23457E-12"], - [0.000000000012345678912345, 0, "1.23457E-11"], - [0.00000000012345678912345, 0, "1.23457E-10"], - [0.0000000012345678912345, 0, "1.23457E-09"], - [0.000000012345678912345, 0, "1.23457E-08"], - [0.00000012345678912345, 0, "1.23457E-07"], - [0.0000012345678912345, 0, "1.23457E-06"], - [0.000012345678912345, 0, "1.23457E-05"], - [0.00012345678912345, 0, "0.000123457"], - [0.0012345678912345, 0, "0.001234568"], - [0.012345678912345, 0, "0.012345679"], - [0.12345678912345, 0, "0.123456789"], - [1.2345678912345, 0, "1.234567891"], - [12.345678912345, 0, "12.34567891"], - [123.45678912345, 0, "123.4567891"], - [1234.5678912345, 0, "1234.567891"], - [12345.678912345, 0, "12345.67891"], - [123456.78912345, 0, "123456.7891"], - [1234567.8912345, 0, "1234567.891"], - [12345678.912345, 0, "12345678.91"], - [123456789.12345, 0, "123456789.1"], - [1234567891.2345, 0, "1234567891"], - [12345678912.345, 0, "12345678912"], - [123456789123.45, 0, "1.23457E+11"], - [1234567891234.5, 0, "1.23457E+12"], - [12345678912345, 0, "1.23457E+13"], - [123456789123450, 0, "1.23457E+14"], - - [0.0000000000000123456789123456, 0, "1.23457E-14"], - [0.000000000000123456789123456, 0, "1.23457E-13"], - [0.00000000000123456789123456, 0, "1.23457E-12"], - [0.0000000000123456789123456, 0, "1.23457E-11"], - [0.000000000123456789123456, 0, "1.23457E-10"], - [0.00000000123456789123456, 0, "1.23457E-09"], - [0.0000000123456789123456, 0, "1.23457E-08"], - [0.000000123456789123456, 0, "1.23457E-07"], - [0.00000123456789123456, 0, "1.23457E-06"], - [0.0000123456789123456, 0, "1.23457E-05"], - [0.000123456789123456, 0, "0.000123457"], - [0.00123456789123456, 0, "0.001234568"], - [0.0123456789123456, 0, "0.012345679"], - [0.123456789123456, 0, "0.123456789"], - [1.23456789123456, 0, "1.234567891"], - [12.3456789123456, 0, "12.34567891"], - [123.456789123456, 0, "123.4567891"], - [1234.56789123456, 0, "1234.567891"], - [12345.6789123456, 0, "12345.67891"], - [123456.789123456, 0, "123456.7891"], - [1234567.89123456, 0, "1234567.891"], - [12345678.9123456, 0, "12345678.91"], - [123456789.123456, 0, "123456789.1"], - [1234567891.23456, 0, "1234567891"], - [12345678912.3456, 0, "12345678912"], - [123456789123.456, 0, "1.23457E+11"], - [1234567891234.56, 0, "1.23457E+12"], - [12345678912345.6, 0, "1.23457E+13"], - [123456789123456, 0, "1.23457E+14"], - - [-0.00000000000001234567, 0, "-1.23457E-14"], - [-0.0000000000001234567, 0, "-1.23457E-13"], - [-0.000000000001234567, 0, "-1.23457E-12"], - [-0.00000000001234567, 0, "-1.23457E-11"], - [-0.0000000001234567, 0, "-1.23457E-10"], - [-0.000000001234567, 0, "-1.23457E-09"], - [-0.00000001234567, 0, "-1.23457E-08"], - [-0.0000001234567, 0, "-1.23457E-07"], - [-0.000001234567, 0, "-1.23457E-06"], - [-0.00001234567, 0, "-1.23457E-05"], - [-0.0001234567, 0, "-0.000123457"], - [-0.001234567, 0, "-0.001234567"], - [-0.01234567, 0, "-0.01234567"], - [-0.1234567, 0, "-0.1234567"], - [-1.234567, 0, "-1.234567"], - [-12.34567, 0, "-12.34567"], - [-123.4567, 0, "-123.4567"], - [-1234.567, 0, "-1234.567"], - [-12345.67, 0, "-12345.67"], - [-123456.7, 0, "-123456.7"], - [-1234567, 0, "-1234567"], - [-12345670, 0, "-12345670"], - [-123456700, 0, "-123456700"], - [-1234567000, 0, "-1234567000"], - [-12345670000, 0, "-12345670000"], - [-123456700000, 0, "-1.23457E+11"], - [-1234567000000, 0, "-1.23457E+12"], - [-12345670000000, 0, "-1.23457E+13"], - [-123456700000000, 0, "-1.23457E+14"], - - [true, 0, "TRUE"], - [false, 0, "FALSE"], - [11.666666666666666, 0, "11.66666667"], [5.057996968497839, 0, "5.057996968"], [4.380353866983808, 0, "4.380353867"],