I was wondering if anyone can tell me how to round a number using Lua? I'm displaying the current share in terabytes, but cause of the division its a really ugly number with 16 numbers after the decimal place. I'd like to round the number to something a little nicer looking, like 2 numbers after the decimal place, but I can't figure out how.
If you paste your script in here, then we can take a look at it.
will not be that hard to realize... 8)
Okay, heres the part of the script I'm having problems with:
function NewUserConnected(curUser)
if (frmHub:GetCurrentShareAmount()/1099511627776 > MaxShare) then
MaxShare = frmHub:GetCurrentShareAmount()/1099511627776
end
if (frmHub:GetUsersCount() > MaxUsers) then
MaxUsers = frmHub:GetUsersCount()
end
end
function showstats(userobj)
userobj:SendData(BotName," Largest # of users connected:"..MaxUsers)
userobj:SendData(BotName," Largest total share:"..MaxShare.." TB")
end
Everything works okay, I'd jsut like to be able to round MaxShare to 2 decimal places, cause the division to get it into terabytes makes the number really ugly.
maybe this
share = format("%.2f",share)
thanks, thats exactly what I was looking for.