Module:Math: Difference between revisions

m
fix
en>Dragons flight
(Add support for rounding to specified precsion)
en>Dragons flight
m (fix)
Line 17:
-- Determine order of magnitude
function z.order(frame)
return pz._order(tonumber(frame.args[1] or frame.args.x or 0))
end
function z._order(x)
Line 111:
local value = tonumber( frame.args[1] or 0 );
local precision = tonumber( frame.args[2] or 0 );
local current_precision = pz._precision( value );
-- If rounding off, truncate extra digits
Line 123:
-- Handle cases requiring scientific notation
order = pz._order( value );
if string.find( formatted_num, 'E', 1, true ) ~= nil or math.abs(order) >= 9 then
value = value * math.pow( 10, -order );
Anonymous user