Hotfix very large number to extend kmbt with qQsSon.

This commit is contained in:
Olivier Gagnon 2021-05-27 14:03:53 -04:00
parent 9d1e132d11
commit f14f65814a
4 changed files with 12 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -716,7 +716,7 @@ class DevMenuComponent extends Component {
<button className="std-button" onClick={this.addMoney(1e9)}>Add $1b</button>
<button className="std-button" onClick={this.addMoney(1e12)}>Add $1t</button>
<button className="std-button" onClick={this.addMoney(1e15)}>Add $1000t</button>
<button className="std-button" onClick={this.addMoney(1e99)}>Add $1e99</button>
<button className="std-button" onClick={this.addMoney(1e25)}>Add $1e99</button>
<button className="std-button" onClick={this.upgradeRam}>Upgrade Home Computer's RAM</button>
</div>
<div className="row">

@ -53,6 +53,15 @@ class NumeralFormatter {
}
formatMoney(n: number): string {
if(numeral.options.currentLocale === "en") {
const extraFormats = [1e15, 1e18, 1e21, 1e24, 1e27, 1e30];
const extraNotations = ['q', 'Q', 's', 'S', 'o', 'n'];
for(let i = 0; i < extraFormats.length; i++) {
if(extraFormats[i] < n && n <= extraFormats[i]*1000) {
return '$'+this.format(n/extraFormats[i], '0.000')+extraNotations[i];
}
}
}
if(Math.abs(n) < 1000) {
return this.format(n, "$0.00");
}