This commit is contained in:
Ben Wilson
2023-07-21 22:55:35 -04:00
parent 82cbb38ea6
commit aad653bf0b

View File

@@ -13,13 +13,16 @@ export class HashSuffixPipe implements PipeTransform {
public transform(value: number): string {
if (value == null || value == 0) {
if (value == null || value < 0) {
return '0';
}
const suffixes = [' H/s', ' KH/s', ' MH/s', ' GH/s', ' TH/s', ' PH/s', ' EH/s'];
const power = Math.floor(Math.log10(value) / 3);
let power = Math.floor(Math.log10(value) / 3);
if (power < 0) {
power = 0;
}
const scaledValue = value / Math.pow(1000, power);
const suffix = suffixes[power];