Modul:Popis stanovništva: razlika između inačica

Izbrisani sadržaj Dodani sadržaj
m bolje ? nego greška :)
m +provjera brojeva za greške pri unosu
Redak 22:
return a.ime < b.ime
end
 
function calculate_logarithmic_percentage_change(current_population, previous_population)
if current_population <= 10 or previous_population <= 10 then
return nil -- Handle cases where populations are non-positive
end
local log_percent_change = math.abs((math.log(current_population) - math.log(previous_population)) / math.log(previous_population)) * 100
--mw.log(previous_population, " to ", current_population, " = ", log_percent_change)
return log_percent_change
end
 
 
 
Line 87 ⟶ 97:
[3] = 0,
}
 
local provjeriti = false
Line 95 ⟶ 107:
zbroj[2] = zbroj[2] + (tonumber(v['popis' .. godinePopisa[2]]) or 0)
zbroj[3] = zbroj[3] + (tonumber(v['popis' .. godinePopisa[3]]) or 0)
end
 
 
local test = calculate_logarithmic_percentage_change((tonumber(v['popis' .. godinePopisa[2]]) or 0), (tonumber(v['popis' .. godinePopisa[1]]) or 0))
local testt = calculate_logarithmic_percentage_change((tonumber(v['popis' .. godinePopisa[3]]) or 0), (tonumber(v['popis' .. godinePopisa[2]]) or 0))
-- mw.log(test, testt)
if (test ~= nil and test > 50) or (testt ~= nil and testt > 50) then
provjeriti = true
end
 
end
 
ret=ret.. '\n|-\n| colspan="4" | <hr>\n'
Line 127 ⟶ 150:
end
end
if provjeriti == true then
ret = ret .. '[[Kategorija:Popis stanovništva: velike promjene]]' end
return ret..'\n'