In working on my quizzing runtime I am running into a problem in trying to determine the maximum number of pages. What I am running into is fractional numbers being rounded down rather than up. Is there a way to force a number to round up rather than down?
Here is what I am doing
<font color=green>%MaxPageNum% = Evaluate (%NumFiles% / 4.0)</font color=green>
This will divide the total number of questions by the maximum displayable per page. What is happening is that I have 10 questions that when divided by 4.0 gives me 2.5. If I divided by 4 it would give me 2, but I will actually have three pages. Is there an easy way to have it take the 2.5 and round up to 3?
My thought on how to approach it was to parse the string grabbing the number before the "." and then check to see if the number returned was greater than the number before the ".". If it is, then I would add 1 to the number.
Something like this
<font color=green>%MaxPageNum% = Evaluate (%NumFiles% / 4.0)
%NewString% = String.GetDelimitedString ("%MaxPageNum%", ".", 0)
IF (%MaxPageNum% > %NewString%)
%MaxPageNum% = Evaluate (%NewString% + 1)
END IF</font color=green>
But is there an easier way?
Here is what I am doing
<font color=green>%MaxPageNum% = Evaluate (%NumFiles% / 4.0)</font color=green>
This will divide the total number of questions by the maximum displayable per page. What is happening is that I have 10 questions that when divided by 4.0 gives me 2.5. If I divided by 4 it would give me 2, but I will actually have three pages. Is there an easy way to have it take the 2.5 and round up to 3?
My thought on how to approach it was to parse the string grabbing the number before the "." and then check to see if the number returned was greater than the number before the ".". If it is, then I would add 1 to the number.
Something like this
<font color=green>%MaxPageNum% = Evaluate (%NumFiles% / 4.0)
%NewString% = String.GetDelimitedString ("%MaxPageNum%", ".", 0)
IF (%MaxPageNum% > %NewString%)
%MaxPageNum% = Evaluate (%NewString% + 1)
END IF</font color=green>
But is there an easier way?
Comment