From 100012d2bebf99e79396e426132c7b7e0d432cf2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 9 Jul 2024 20:05:23 +0900 Subject: fix: f32.convert_i(32|64)_(s|u) --- src/Execution/Runtime.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index e67921f..02c526c 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -592,25 +592,25 @@ final class Runtime private function execInstrNumericF32ConvertI32S(Instrs\Numeric\F32ConvertI32S $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue((float) $v); + $this->stack->pushValue(NumericOps::truncateF64ToF32((float) $v)); } private function execInstrNumericF32ConvertI32U(Instrs\Numeric\F32ConvertI32U $instr): void { - $v = $this->stack->popInt(); - $this->stack->pushValue((float) $v); + $v = NumericOps::convertS32ToU32($this->stack->popInt()); + $this->stack->pushValue(NumericOps::truncateF64ToF32((float) $v)); } private function execInstrNumericF32ConvertI64S(Instrs\Numeric\F32ConvertI64S $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue((float) $v); + $this->stack->pushValue(NumericOps::truncateF64ToF32((float) $v)); } private function execInstrNumericF32ConvertI64U(Instrs\Numeric\F32ConvertI64U $instr): void { $v = $this->stack->popInt(); - $this->stack->pushValue((float) $v); + $this->stack->pushValue(NumericOps::truncateF64ToF32((float) $v)); } private function execInstrNumericF32CopySign(Instrs\Numeric\F32CopySign $instr): void -- cgit v1.2.3-70-g09d2