diff --git a/generators/builtins/primitives/WasmPrimitivesGenerator.kt b/generators/builtins/primitives/WasmPrimitivesGenerator.kt index ffa4e1ae7e5..8652ccdde3b 100644 --- a/generators/builtins/primitives/WasmPrimitivesGenerator.kt +++ b/generators/builtins/primitives/WasmPrimitivesGenerator.kt @@ -101,7 +101,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } } "rem" -> when (thisKind) { - in PrimitiveType.floatingPoint -> "this - (wasm_${thisKind.prefixLowercase}_nearest(this / $parameterName) * $parameterName)" + in PrimitiveType.floatingPoint -> "this - (wasm_${thisKind.prefixLowercase}_truncate(this / $parameterName) * $parameterName)" else -> return implementAsIntrinsic(thisKind, methodName) } else -> return implementAsIntrinsic(thisKind, methodName) diff --git a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt index 6c00e4ba716..086dd2c01c2 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt @@ -2146,7 +2146,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public operator fun rem(other: Float): Float = - this - (wasm_f32_nearest(this / other) * other) + this - (wasm_f32_truncate(this / other) * other) /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2552,7 +2552,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public operator fun rem(other: Double): Double = - this - (wasm_f64_nearest(this / other) * other) + this - (wasm_f64_truncate(this / other) * other) /** * Returns this value incremented by one.