2,875
edits
(Add magical autoround function) |
m (Rename parameter p that conflicts with parent) |
||
Line 17: | Line 17: | ||
} | } | ||
local function sigfig(x, | local function sigfig(x, y) | ||
local x_sign = x < 0 and -1 or 1 | local x_sign = x < 0 and -1 or 1 | ||
local x = math.abs(x) | local x = math.abs(x) | ||
local n = math.floor(math.log10(x)) + 1 - | local n = math.floor(math.log10(x)) + 1 - y | ||
return x_sign * math.pow(10, n) * | return x_sign * math.pow(10, n) * y.round2(x / math.pow(10, n), 0) | ||
end | end | ||
edits