-- useful number conversions bit.hex = function (num) return bit.tostring (num, 16) end bit.oct = function (num) return bit.tostring (num, 8) end bit.bin = function (num) return bit.tostring (num, 2) end result = setfenv (assert (loadstring "return %1"), setmetatable ({}, {__index = function (_, n) return math [n] or bit [n] or string [n] or utils [n] or world [n] end}) ) () -- turn result into a string, to see if it has "e-xxx" in it. formatted_result = tostring (result) -- if an exponent shown, recalculate as a decimal without exponent if string.match (formatted_result, "e%%-") then local extra = string.format (" (%%0.15f)", result) -- append number without exponent, omitting trailing zeroes formatted_result = formatted_result .. string.gsub (extra, "0+%%)", ")") end -- if -- display result print ("%1 =", formatted_result)