novo Posted March 11, 2013 Share Posted March 11, 2013 Hello, I want to create a percentage from an amout of bytes. I'm having the following code; local bytes = 0 for i,v in ipairs(clientCreate) do local bytes = bytes + fileGetSize(":"..res.."/"..v) end local percent = bytes/100 Now I want to take a % from the percent I just created by comparing, here: Lets think that the bytes is equal to 54000 B local bytes = 54000 local percent = 54000/100 local percent = 540 --% Now I want to know what % would be if I'm having 50000 B instead of 54000, 4000 B are left. I hope you understood me! Thanks in advance. Link to comment
qaisjp Posted March 12, 2013 Share Posted March 12, 2013 To calculate percentages first calculate the fraction: decimal=CURRENT_VALUE/MAX_VALUE then multiple by 100 to make it a percentage (otherwise it's a decimal) this means it is percent = (CURRENT_VALUE/MAX_VALUE)*100 Link to comment
FFS-Racing Posted March 12, 2013 Share Posted March 12, 2013 Grade school maths isn't your strong suit? Seriously, if you don't know the essence of percentage, then what are you doing in the scripting section. Mathetmatical logic is the foundation of programming/scripting. Link to comment
novo Posted March 12, 2013 Author Share Posted March 12, 2013 Well, as far I know I'm not the only one who doesn't know maths very well. By the way, I searched on the internet and I didn't understand what the people meant and that's why I came here to ask. And, the education and the respect aren't your strong suits I see. Link to comment
qaisjp Posted March 12, 2013 Share Posted March 12, 2013 novo, you need some skill in Physics and more skill in Mathematics for programming/scripting. "And, the education and the respect aren't your strong suits I see", ffs-racing is being honest and seriously - education? I don't have any respect for noobs, I have respect for newbies though. I have respect to people who really want to code. I don't have respect for people who don't try and bother everyone else because of it. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now