Renamed previous Scientific Notation to Engineering Notation and added real Scientific Notation (Issue #110)

This commit is contained in:
Aktanusa
2018-07-12 23:05:18 -04:00
parent b5f6fef9ae
commit 22ae4ebc4c
3 changed files with 44 additions and 20 deletions

View File

@@ -540,7 +540,7 @@ CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra
CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false}; CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false};
CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false}; CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false};
CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}}; CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}};
CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Engineering Notation', 'Scientific Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}};
/******** /********
* Data * * Data *
@@ -649,17 +649,29 @@ CM.Disp.Beautify = function(num, frac) {
negative = true; negative = true;
} }
for (var i = (CM.Disp.shortScale.length - 1); i >= 0; i--) { if (CM.Config.Scale == 4) {
if (i < CM.Disp.metric.length && CM.Config.Scale == 1) { if (num > 9) {
if (num >= Math.pow(1000, i + 2)) { var count = 0;
answer = (Math.floor(num / Math.pow(1000, i + 1)) / 1000).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' ' + CM.Disp.metric[i]; while (num > 9) {
break; count++;
num /= 10;
} }
answer = Math.round(num * 1000) / 1000 + 'E+' + count;
} }
else if (CM.Config.Scale > 1) { }
if (num >= Math.pow(1000, i + 2)) { else {
answer = (Math.floor(num / Math.pow(1000, i + 1)) / 1000) + (CM.Config.Scale == 2 ? (' ' + CM.Disp.shortScale[i]) : ('e+' + ((i + 2) * 3))); for (var i = (CM.Disp.shortScale.length - 1); i >= 0; i--) {
break; if (i < CM.Disp.metric.length && CM.Config.Scale == 1) {
if (num >= Math.pow(1000, i + 2)) {
answer = (Math.round(num / Math.pow(1000, i + 1)) / 1000).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' ' + CM.Disp.metric[i];
break;
}
}
else if (CM.Config.Scale > 1) {
if (num >= Math.pow(1000, i + 2)) {
answer = (Math.round(num / Math.pow(1000, i + 1)) / 1000) + (CM.Config.Scale == 2 ? (' ' + CM.Disp.shortScale[i]) : ('E+' + ((i + 2) * 3)));
break;
}
} }
} }
} }

View File

@@ -146,5 +146,5 @@ CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra
CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false}; CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false};
CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false}; CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false};
CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}}; CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}};
CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Engineering Notation', 'Scientific Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}};

View File

@@ -97,17 +97,29 @@ CM.Disp.Beautify = function(num, frac) {
negative = true; negative = true;
} }
for (var i = (CM.Disp.shortScale.length - 1); i >= 0; i--) { if (CM.Config.Scale == 4) {
if (i < CM.Disp.metric.length && CM.Config.Scale == 1) { if (num > 9) {
if (num >= Math.pow(1000, i + 2)) { var count = 0;
answer = (Math.floor(num / Math.pow(1000, i + 1)) / 1000).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' ' + CM.Disp.metric[i]; while (num > 9) {
break; count++;
num /= 10;
} }
answer = Math.round(num * 1000) / 1000 + 'E+' + count;
} }
else if (CM.Config.Scale > 1) { }
if (num >= Math.pow(1000, i + 2)) { else {
answer = (Math.floor(num / Math.pow(1000, i + 1)) / 1000) + (CM.Config.Scale == 2 ? (' ' + CM.Disp.shortScale[i]) : ('e+' + ((i + 2) * 3))); for (var i = (CM.Disp.shortScale.length - 1); i >= 0; i--) {
break; if (i < CM.Disp.metric.length && CM.Config.Scale == 1) {
if (num >= Math.pow(1000, i + 2)) {
answer = (Math.round(num / Math.pow(1000, i + 1)) / 1000).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' ' + CM.Disp.metric[i];
break;
}
}
else if (CM.Config.Scale > 1) {
if (num >= Math.pow(1000, i + 2)) {
answer = (Math.round(num / Math.pow(1000, i + 1)) / 1000) + (CM.Config.Scale == 2 ? (' ' + CM.Disp.shortScale[i]) : ('E+' + ((i + 2) * 3)));
break;
}
} }
} }
} }