I need the easiest and shortes way, to round an integer to the next "30-series".
For example:
431 --> 450
459 --> 480
298 --> 300
I need the easiest and shortes way, to round an integer to the next "30-series".
For example:
431 --> 450
459 --> 480
298 --> 300
It depends on the language you are using. A simple example could be
def round2multipleOfThirty(x):
if x % 30 < 15:
return x - x % 30
else:
return x + 30 - x % 30
which works in python. But do you actually want a round function? Your example numbers are always rounded up to the next greater multiple of 30. My function provided is a round which would provide
431 --> 420
459 --> 450
298 --> 300