Results 1 to 2 of 2

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

  1. #1
    Join Date
    Apr 2011
    Seattle, WA

    Exclamation 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", which will always be completed in order, 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 40% complete because 7/15=.466 a.k.a.. 47% complete.

    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 not 50% complete.

    Any help would be greatly appreciated; thanks!

  2. #2
    Join Date
    Aug 2004
    PHP Code:
    $percent floor(($total $count) * 10) * 10
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center