diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java index 1725fed14f..8bd7c98f88 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java @@ -413,7 +413,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4)); if (smallCarbAmount == 0) smallCarbAmount = 1; while (remainingCarbs > 0) { - createCarb(smallCarbAmount, carbTime); + createCarb(Math.min(smallCarbAmount, (long) remainingCarbs), carbTime); remainingCarbs -= smallCarbAmount; carbTime += 15 * 60 * 1000; }