Consommer nourriture, suite #168

This commit is contained in:
Vincent Vandemeulebrouck
2021-04-11 23:01:10 +02:00
parent 6b31e81c72
commit 3d8453dc2d
7 changed files with 189 additions and 159 deletions

View File

@ -47,7 +47,11 @@ export class Misc {
const parsed = parseInt(value);
return isNaN(parsed) ? 0 : parsed;
}
static keepDecimals(num, decimals) {
if (decimals<=0 || decimals>6) return num;
const decimal = Math.pow(10, parseInt(decimals));
return Math.round(num * decimal) / decimal;
}
static getFractionHtml(diviseur) {
if (!diviseur || diviseur <= 1) return undefined;
switch (diviseur || 1) {