Calculating percentage in MEW 11.04 question

Product Compare Forums Multi-Edit Support Calculating percentage in MEW 11.04 question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2800
    MewUser
    Participant

    Hello,

    I would like to be able to calculate and display a percentage; However, the dialog shows a value of 0.0000.
    The actual value of NumDifferent = 27, and NumWatch = 1335;
    Per calculation, the actual value should be 1.9823

    Does anyone have any suggestions on how to get this to work properly? Thank you.

    Here is my code:

    Real RTotal;
    Str RealStr;
    int NumDifferent, NumWatch;

    MsgDlg ( "NumMatch "+str(NumMatch)+" NumDifferent "+str(NumDifferent), "", "CheckYZ", 1);
    // Calculate percentage of differences versus combined.
    int Total = NumDifferent+NumMatch;
    MsgDlg ( "Total "+str(Total), "", "CheckYZ", 1);
    RTotal = Real_I((NumDifferent/Total)*100);
    RealStr = Rstr( RTotal, 7, 4 );
    MsgDlg ( "Percent "+RealStr, "", "CheckYZ", 1);

    #9124
    tlscales
    Participant

    Problem is you are converting the result of an int operation which has already evaluated to an integer 0 to real. You need to make NumDifferent and Total real values, so the division operation is not rounded to the nearest int.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.