//FIXME: private static int g_write(Lua L, PrintStream stream, int arg) { //FIXME: int nargs = L.Top; //FIXME:notice here, original code is 'lua_gettop(L) - 1' (something pushed before?) int status = 1; for (; nargs != 0; arg++) { nargs--; if (L.type(arg) == Lua.TNUMBER) { if (status != 0) { try { //stream.print(String.format("%s", L.toNumber(L.value(arg)))); //@see http://stackoverflow.com/questions/703396/how-to-nicely-format-floating-numbers-to-string-without-unnecessary-decimal-0 //stream.print(new DecimalFormat("#.##########").format(L.value(arg))); //@see Lua#vmToString FormatItem f = new FormatItem(null, NUMBER_FMT); StringBuilder b = new StringBuilder(); double? d = (double?)L.toNumber(L.value(arg)); f.formatFloat(b, (double)d); stream.print(b.ToString()); } catch (Exception) { status = 0; } } } else { string s = L.checkString(arg); if (status != 0) { try { stream.print(s); } catch (Exception) { status = 0; } } } } return(pushresult(L, status, null)); }