diff --git a/src/RowWorkItem.svelte b/src/RowWorkItem.svelte index c561e27078f67e5d4e9e620863ae931687b75716..9248a31a2bed45b87454c6d370ccafc1a7846804 100644 --- a/src/RowWorkItem.svelte +++ b/src/RowWorkItem.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { calculateE, calculateS, calculateV } from "./estimator"; - import { roundOne } from "./utils"; + import { roundTwo } from "./utils"; export let a: number export let b: number @@ -27,8 +27,8 @@ <td class="tg-0lax"> <input type="number" class="c-input" bind:value="{b}"> </td> - <td class="tg-0lax">{hideNull(roundOne(E))}</td> - <td class="tg-0lax">{hideNull(roundOne(S))}</td> - <td class="tg-0lax">{hideNull(roundOne(SEPercent))}%</td> - <td class="tg-0lax">{hideNull(roundOne(V))}</td> + <td class="tg-0lax">{hideNull(roundTwo(E))}</td> + <td class="tg-0lax">{hideNull(roundTwo(S))}</td> + <td class="tg-0lax">{hideNull(roundTwo(SEPercent))}%</td> + <td class="tg-0lax">{hideNull(roundTwo(V))}</td> </tr> \ No newline at end of file diff --git a/src/SumRow.svelte b/src/SumRow.svelte index 7c76aa6ea5e710af655bdb4bcfca5e4fa2f86525..2c6748c6309add956e150f43c2141f98effcb5c0 100644 --- a/src/SumRow.svelte +++ b/src/SumRow.svelte @@ -1,7 +1,7 @@ <script lang="ts"> import type { WorkPackage } from "./estimator"; import { calculateSSum, calculateESum, calculateVSum } from './estimator'; - import { roundOne, sumIgnoreNonNumbers } from "./utils"; + import { roundTwo, sumIgnoreNonNumbers } from "./utils"; export let workPackages: WorkPackage[] export let r: number = NaN; @@ -18,14 +18,14 @@ ∑ {sumIgnoreNonNumbers(workPackages.map(workPackage => workPackage.b))} </td> <td class="tg-0lax"> - ∑ {roundOne(calculateESum(workPackages, r))} + ∑ {roundTwo(calculateESum(workPackages, r))} </td> <td class="tg-0lax"> - {roundOne(calculateSSum(workPackages, u))} + {roundTwo(calculateSSum(workPackages, u))} </td> <td class="tg-0lax"> </td> <td class="tg-0lax"> - ∑ {roundOne(calculateVSum(workPackages, u))} + ∑ {roundTwo(calculateVSum(workPackages, u))} </td> </tr> \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 57ec0a2f52ec223dfcf00ca10f59fdec9d34bfda..21ada1b3617041aebd8cdaf2102ca06179083fc3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,10 +1,10 @@ /** - * Rounds a number to one digit after the period dot or null, if the input is not a number + * Rounds a number to two digits after the period dot or null, if the input is not a number * @param n number to round */ -export function roundOne(n: number): number | null { +export function roundTwo(n: number): number | null { if (typeof n === "number" && !isNaN(n)) { - return Math.round(n * Math.pow(10, 1)) / Math.pow(10, 1); + return Math.round(n * Math.pow(10, 2)) / Math.pow(10, 2); } else { return null; }