string.format %f ignores precision
Brought to you by:
ian_farmer,
jim_roseborough
string.format('%2f', 1.23456)
returns 1.23456 instead of 1.23
Here's a test case
@Test public void stringFormat() throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine e = mgr.getEngineByName("luaj"); e.eval("y = string.format('%.2f', 1.23456)"); Assert.assertEquals("1.23", (String) e.get("y")); }