[Circuits] Round up when dividing?
-
- Manual Inserter
- Posts: 1
- Joined: Fri Feb 04, 2022 12:39 am
- Contact:
[Circuits] Round up when dividing?
Title says it all really. The arithmetic combinator rounds down when it divides, but I need it to always round up instead. What's the most compact way to do this? My first thought was add 1, but that doesn't work if the division gives an integer.
Re: [Circuits] Round up when dividing?
Add (Divisor - 1) before you do the division.
Re: [Circuits] Round up when dividing?
Sorry for necroposting but either i missunderstand something or the answer is wrong. simple example:
10 / 9 with round up would be 2, because 10/9 = 1.111...... with rounding up it gives 2. putting this in an arithmetic still outputs 1 because is rounds down after calculation
10 / 9 with round up would be 2, because 10/9 = 1.111...... with rounding up it gives 2. putting this in an arithmetic still outputs 1 because is rounds down after calculation
Every good story ends with System.exit(0);
- Stringweasel
- Filter Inserter
- Posts: 468
- Joined: Thu Apr 27, 2017 8:22 pm
- Contact:
Re: [Circuits] Round up when dividing?
Seems correct to meDasNasu wrote: Tue Jun 13, 2023 5:22 am Sorry for necroposting but either i missunderstand something or the answer is wrong. simple example:
(10 + (9-1)) / 9 = 18 / 9 = 2
And if your round 2 down, it's still 2. If it's not working for you in-game then there might be a problem in how you used it.
Alt-F4 Author | Factorio Modder
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration
Probably known for: (Configurable) Valves | Better Victory Screen | Space Spidertron | Fluidic Power
Official Contributor to Space Exploration