Anonymous

Module:Number: Difference between revisions

From Melvor Idle
m
Rename parameter p that conflicts with parent
(Add magical autoround function)
m (Rename parameter p that conflicts with parent)
Line 17: Line 17:
     }
     }


local function sigfig(x, p)
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 - p
local n = math.floor(math.log10(x)) + 1 - y
return x_sign * math.pow(10, n) * p.round2(x / math.pow(10, n), 0)
return x_sign * math.pow(10, n) * y.round2(x / math.pow(10, n), 0)
end
end


913

edits