All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jtransc.numeric.multiples.kt Maven / Gradle / Ivy

package com.jtransc.numeric

private fun roundUp(numToRound:Int, multiple:Int): Int
{
	if (multiple == 0)
		return numToRound;

	val remainder = Math.abs(numToRound) % multiple;
	if (remainder == 0)
		return numToRound;

	if (numToRound < 0)
		return -(Math.abs(numToRound) - remainder);
	else
		return numToRound + multiple - remainder;
}

fun Int.nextMultipleOf(multiple:Int):Int = roundUp(this, multiple)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy