The following code is from the ElvUI math.lua file. I've slightly altered it from showing decimal points to not showing them. However, I want to show decimal points for numbers less than 10 million, and higher than 1 million.
I'm having a strange issue with it. When I target a mob that has 1,467,810 HP, it properly displays 1.5m. However, when I target a mob that has 29,356,200 HP, it displays 3m, when it should display 30m.
Code:
function E:ShortValue(v)
if v >= 1e9 then
return ("%.fb"):format(v / 1e9):gsub("%.?+([kmb])$", "%1")
elseif v >= 1e7 then
return ("%.fm"):format(v / 1e7):gsub("%.?+([kmb])$", "%1")
elseif abs(v) >= 1e6 then
return format("%.1fm", v / 1e6)
elseif v >= 1e3 or v <= -1e3 then
return ("%.fk"):format(v / 1e3):gsub("%.?+([kmb])$", "%1")
else
return v
end
end