percent
I want to make percent
so this is code is how many Achievements you got Code:
TotalAchievements[id]Code:
iTotalAchievementsYou got 6 of 13 Achievements done And this is the question, how can i make so it look like this example: You got 30 % of 100 % Achievements done Thanks :) |
Re: percent
( Total Achievements / Earned Achievements ) * 100 = Percentage
|
Re: percent
You made a little mistake and also to make it work with integers the formula should look like this:
100 * Earned Achievements / Total Achievements |
Re: percent
Can you show me in code version?
|
Re: percent
Quote:
PHP Code:
|
Re: percent
Umm, the division has the same priority as multiplication and it executes them in order from left to right, so it will work fine.
PHP Code:
|
Re: percent
I didn't say anything about order of operations.
3 / 5 = 0 3.0 / 5.0 = 0.6 Both variables need to be converted to floating point values before they can be divided. To get an integer as an output you would need to do this: PHP Code:
|
Re: percent
or you can show the decimals only
PHP Code:
|
Re: percent
@fysiks: You don't need to work with floats as long as you multiply the numerator by 100 first. I think that is what Sylwester was getting at...
|
Re: percent
Hey Use Math :D
|
| All times are GMT -4. The time now is 13:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.