CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Location
    Pakistan
    Posts
    466

    Question Percentage calc formulla needed - little maths

    Description:

    We have total number of processes 'T' which are being performed. e.g. 10.

    Then we already have number of processes done 'D' and number of processes pebding 'P', and we have percent of the process currently being executed.

    Question:

    How to calcualte overall percentage ?

    What I did was:

    overall percentage =
    (((processes done + (percent of current * 0.1)) / total processes) * 100;

    in code:

    float overall_peercentage = (((D + (C * 0.1)) / T) * 100;



    But it does not produce 100% results, what is wrong with it? Secondly, I dont feel ashamed askin this question, becuae I am not a mathematician.


    regards
    » Please 'Rate This Post' if it helped (encourage us to help you more)
    » Build GUI in minute using rad c++
    » Free IDE + GUI code generator - screenshot
    » Free WINAPI sourcecode and tutorials

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: Percentage calc formulla needed - little maths

    (D + P1 + P2 + P3 + ...) / (D + P) * 100 is the correct formula where P1, P2 etc. is the amount of work the process Pi has done (with 1 as maximum). If the processes that are still running all have the same percentage, then it's a bit easier. It's just
    (D + Pp)/(D + P) * 100 where Pp is the percentage (with 0 as minimum and 1 as maximum) done for the processes still running.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured