Skip to content

Commit

Permalink
fix: PrintFloat shouldn't add .0 to integral values
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsci authored and jbmorley committed Mar 3, 2022
1 parent 0c01f8e commit ea8f120
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea8f120

Please sign in to comment.