aim for 3 sig.fig.

This commit is contained in:
Max Howell 2023-04-20 13:41:18 -04:00
parent 46a907e85c
commit 732cb56860
No known key found for this signature in database
GPG key ID: 741BB84EF5BB9EEC

View file

@ -25,7 +25,8 @@
}
const N = n / divisor;
const decimals = n < 10 ? 2 : 1; // its more informative to show more decimals but only for smaller numbers
// going for 3 significant figures
const decimals = N < 10 ? 2 : N < 100 ? 1 : 0;
return `${N.toFixed(decimals)} ${unit}`;
};