Module:Shared: Difference between revisions

moved numStrWithSign here from Items/ComparisonTables
(Replace GCD function with an implementation of the Euclidean algorithm, so that fewer iterations occur when numbers differ greatly in magnitude)
(moved numStrWithSign here from Items/ComparisonTables)
Line 344: Line 344:
end
end


--Checks if two tables contain the same value with the same indices
function p.tablesEqual(t1, t2)
function p.tablesEqual(t1, t2)
   if p.tableCount(t1) ~= p.tableCount(t2) then return false end
   if p.tableCount(t1) ~= p.tableCount(t2) then return false end
Line 356: Line 357:
   end
   end
   return true
   return true
end
--Returns a number including the sign, even if positive
function p.numStrWithSign(number)
  if number >= 0 then
    return '+'..Shared.formatnum(number)
  else
    return Shared.formatnum(number)
  end
end
end


return p
return p