How to round up a number if it's not an integer?
You can use math.ceil
to round a Double
up and toInt
to convert the Double
to an Int
.
def roundUp(d: Double) = math.ceil(d).toInt
roundUp(1.2) // Int = 2
roundUp(3.7) // Int = 4
roundUp(5) // Int = 5