Ankit Shah
12/22/2021, 5:15 PM(10/3).toInt()
it returns 3 but what I want is the upper value i.e. 4. How can I achieve it?Igor Milakovic
12/22/2021, 5:17 PMceil
of 10/3
before toInt()
?Ankit Shah
12/22/2021, 5:29 PMruitzei
12/22/2021, 5:57 PMint
from that, one of the operands should be a double
or a float
to get that desired behaviour.elizarov
12/22/2021, 7:35 PM(10 + 3 - 1) / 3
ruitzei
12/22/2021, 7:51 PMnominator + denominator
doesn’t overflow 😂Diego Rodriguez
12/22/2021, 8:56 PM1 + (nominator - 1) / denominator
, e.g. 1 + (10 - 1) / 3
mcpiroman
12/31/2021, 3:36 PMinfix fun Int.divUp(denominator: Int) = 1 + (this - 1) / denominator // delegate handling of division by 0 to the / operator
might need special handling for nevative values though.