Skip to content

Commit

Permalink
Rounding instead of trunc
Browse files Browse the repository at this point in the history
  • Loading branch information
pcboy committed Jan 4, 2021
1 parent 4264c0d commit a7783ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"mobx-state-tree": "^4.0.2",
"msgpack-lite": "^0.1.26",
"parcel": "^1.12.4",
"react": "^16.8.0",
"react": "*",
"react-contenteditable": "^3.3.4",
"react-dom": "^16.8.0",
"react-github-corner": "^2.5.0",
Expand Down
4 changes: 2 additions & 2 deletions stores/CalculatorStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const CalculatorStore = types
return self.flours[self.starterFlourIndex];
},
get starterWeight() {
return Math.trunc(self.totalWeight * (self.starterPerc / 100.0));
return Math.round(self.totalWeight * (self.starterPerc / 100.0));
},
}))
.actions((self) => ({
computeWeight(ingredientPerc: number) {
return Math.trunc(
return Math.round(
ingredientPerc *
(self.totalWeight /
(self.ingredients.map((x) => x.dosage).reduce((x, y) => x + y) +
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5018,14 +5018,13 @@ react-transition-group@^4.4.0:
loose-envify "^1.4.0"
prop-types "^15.6.2"

react@^16.8.0:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==
react@*:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"

readable-stream@^2.0.2, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.3, readable-stream@~2.3.6:
version "2.3.7"
Expand Down

0 comments on commit a7783ba

Please sign in to comment.