Use kotlin.math instead of java.lang.Math
ProprietaryReplaces JVM-only java.lang.Math calls with their multiplatform kotlin.math equivalents — top-level functions (abs, sqrt, sin, …), constants (PI, E), and receiver-style extensions on Double/Int/Long (pow, roundToInt, floorDiv, mod, …).
org. openrewrite. kotlin. migrate. UseKotlinMath$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. migrate. UseKotlinMath$KtRecipe'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Use
kotlin.math.absinstead ofjava.lang.Math.abs - Use
kotlin.math.sqrtinstead ofjava.lang.Math.sqrt - Use
kotlin.math.floorinstead ofjava.lang.Math.floor - Use
kotlin.math.ceilinstead ofjava.lang.Math.ceil - Use
kotlin.math.mininstead ofjava.lang.Math.min - Use
kotlin.math.maxinstead ofjava.lang.Math.max - Use
kotlin.math.expinstead ofjava.lang.Math.exp - Use
kotlin.math.lninstead ofjava.lang.Math.log - Use
kotlin.math.log10instead ofjava.lang.Math.log10 - Use
kotlin.math.sininstead ofjava.lang.Math.sin - Use
kotlin.math.cosinstead ofjava.lang.Math.cos - Use
kotlin.math.taninstead ofjava.lang.Math.tan - Use
kotlin.math.asininstead ofjava.lang.Math.asin - Use
kotlin.math.acosinstead ofjava.lang.Math.acos - Use
kotlin.math.ataninstead ofjava.lang.Math.atan - Use
kotlin.math.atan2instead ofjava.lang.Math.atan2 - Use
kotlin.math.sinhinstead ofjava.lang.Math.sinh - Use
kotlin.math.coshinstead ofjava.lang.Math.cosh - Use
kotlin.math.tanhinstead ofjava.lang.Math.tanh - Use
kotlin.math.cbrtinstead ofjava.lang.Math.cbrt - Use
kotlin.math.hypotinstead ofjava.lang.Math.hypot - Use
kotlin.math.expm1instead ofjava.lang.Math.expm1 - Use
kotlin.math.ln1pinstead ofjava.lang.Math.log1p - Use
kotlin.math.signinstead ofjava.lang.Math.signum - Use
kotlin.math.PIinstead ofjava.lang.Math.PI - Use
kotlin.math.Einstead ofjava.lang.Math.E - Use
Double.powinstead ofjava.lang.Math.pow - Use
Double.roundToLong()instead ofjava.lang.Math.round - Use
Float.roundToInt()instead ofjava.lang.Math.round - Use
Double.withSigninstead ofjava.lang.Math.copySign - Use
Double.IEEEreminstead ofjava.lang.Math.IEEEremainder - Use
Double.nextUp()instead ofjava.lang.Math.nextUp - Use
Double.nextDown()instead ofjava.lang.Math.nextDown - Use
Double.nextTowards()instead ofjava.lang.Math.nextAfter - Use
Int.floorDivinstead ofjava.lang.Math.floorDiv - Use
Long.floorDivinstead ofjava.lang.Math.floorDiv - Use
Int.mod()instead ofjava.lang.Math.floorMod - Use
Long.mod()instead ofjava.lang.Math.floorMod - Use
Long.mod(Int)instead ofjava.lang.Math.floorMod