Perhaps I misunderstood the original requirement. I assumed that the actual requirement was for percentage to end up with a value of either 0 or 1. The original code in the first post would do that for integer values but not doubles. It would leave it unchanged for the values from 0 to 0.99999.... That is why I asked for clarification in post #2.