Commit 01e6f3da by Tomas Dvorak

significant digits count fix

parent ef763c8d
...@@ -275,12 +275,11 @@ if($outputFormat === 'json') { ...@@ -275,12 +275,11 @@ if($outputFormat === 'json') {
} else { // output nice ascii table with results } else { // output nice ascii table with results
var table = [['key', 'types', 'occurrences', 'percents'], ['', '', '', '']]; // header + delimiter rows var table = [['key', 'types', 'occurrences', 'percents'], ['', '', '', '']]; // header + delimiter rows
var significantDigits = function(value) { // return the number of decimal places or 1, if the number is int (1.23=>2, 100=>1, 0.1415=>4)
return value.toExponential() var significantDigits = function(value) {
.replace(/e[\+\-0-9]*$/, '') // remove exponential notation var res = value.toString().match(/^[0-9]+\.([0-9]+)$/);
.replace( /^0\.?0*|\./, '') // remove decimal point and leading zeros return res !== null ? res[1].length : 1;
.length; };
};
var maxDigits = Math.max.apply(null, varietyResults.map(function(value){return significantDigits(value.percentContaining);})); var maxDigits = Math.max.apply(null, varietyResults.map(function(value){return significantDigits(value.percentContaining);}));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment