From ea8f120776e849f43a846fbb8ae85574f2d912f9 Mon Sep 17 00:00:00 2001 From: Tom Sutcliffe Date: Thu, 3 Mar 2022 16:00:16 +0000 Subject: [PATCH] fix: PrintFloat shouldn't add .0 to integral values --- src/ops.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ops.lua b/src/ops.lua index d03fe58f..feb3fdc2 100644 --- a/src/ops.lua +++ b/src/ops.lua @@ -1205,7 +1205,18 @@ end PrintInt = PrintUntyped -- 0x88 PrintLong = PrintUntyped -- 0x89 -PrintFloat = PrintUntyped -- 0x8A + +function PrintFloat(stack, runtime) -- 0x8A + local val = stack:pop() + local int = math.tointeger(val) + if int then + -- Whole number floats print without the .0 in OPL + runtime:PRINT(tostring(int)) + else + runtime:PRINT(tostring(val)) + end +end + PrintString = PrintUntyped -- 0x8B function LPrintInt(stack, runtime) -- 0x8C