mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 21:37:49 -05:00
fixed ingredient calculator rounding error
This commit is contained in:
@@ -377,6 +377,10 @@
|
|||||||
trigger: 'focus'
|
trigger: 'focus'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function roundToTwo(num) {
|
||||||
|
return +(Math.round(num + "e+2") + "e-2");
|
||||||
|
}
|
||||||
|
|
||||||
function reloadIngredients() {
|
function reloadIngredients() {
|
||||||
factor = Number($('#in_factor').val());
|
factor = Number($('#in_factor').val());
|
||||||
ingredients = {
|
ingredients = {
|
||||||
@@ -386,7 +390,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var key in ingredients) {
|
for (var key in ingredients) {
|
||||||
$('#ing_' + key).html(Math.round(ingredients[key] * factor))
|
$('#ing_' + key).html(roundToTwo(ingredients[key] * factor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user