/    Sign up×
Community /Pin to ProfileBookmark

Find one tenth of a variable and round up to the next whole number and find remainder

Ok, so I have an undetermined number of entries.. (user can add additional tasks to the list, each project has 1 of each task) I need to know how many are “10 percent” of the total so that I can divide them into 10 more-or-less equal parts.

Each entry has a “status”, [B][I]which will always be completed in order[/I][/B], and if they are complete then I want to be able to say that the total is 10% complete, 20% complete, etc… So if there are 10 of them and 4 are complete, then it would be 40 percent, but if there are 100 of them and 40, 41, 42, 43, 44, etc, to 49 are complete, then it would say 40 percent complete… but likewise if there are 15 tasks then if there are 7 done it would say [I]40% complete[/I] because [B]7/15=.466[/B] a.k.a.. [B]47% complete[/B].

Also, if you noticed, I don’t want it to “round to the nearest 10 percent” I want it to be at or above a percentage when it’s shown, so 49% is [I]not[/I] 50% complete.

Any help would be greatly appreciated; thanks!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 26.2012 — Untested:
[code=php]
$percent = floor(($total / $count) * 10) * 10;
[/code]
×

Success!

Help @amandaNHT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...