pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.6k stars 519 forks source link

In the "Lua quick start guide" in welcome.lua the description of the behavior of the "%.0f" format specifier is wrong. #1133

Closed WraithGlade closed 2 years ago

WraithGlade commented 2 years ago

In the list of examples provided by the "Lua quick start guide", one can find the following excerpt:

-- %.0f placeholder truncates real numbers
print(("%.0f"):format(1.5)) --> 1

This statement is false however. It prints 2, clearly engaging in rounding behavior.

Other test cases (e.g. 5.999999, etc) also round, not truncate.

Perhaps this is a remnant of an old version of Lua. I haven't touched Lua in many years, but trying to freshen up now.

I'm not sure if this should be reported on Git, but it was the only avenue for reporting I found in a few minutes, so here I am.

My apologies if this is not the correct place for reporting it. I don't want to waste a lot of time on it since it is a small thing.

pkulchenko commented 2 years ago

Thank you for the report! This should be fixed in https://github.com/pkulchenko/ZeroBraneEduPack/commit/ff97a4e4a5a8385b594655f424d27147a6619b37.