I have code that is supposed to round a number to the nearest integer. If the first number after the decimal is 5 or greater, it should round up to the next integer. For example:
14.5 would round to 15
14.4999 would round to 14
My code is working unless the number after the decimal is 5. Here's a screenshot I took of me stepping through the code.
You can see that it is reading a number from a cell on a worksheet into a variable called Average. That number is 14.5. It is then rounding that number and putting the new number into another variable called RoundedAverage. But in this case, RoundedAverage should be 15 (shouldn't it?), but instead it is 14. I cannot figure out why.
I tried making both Average and RoundedAverage into type Double, but that made no difference.
Any idea how I can make this work so that the result is 15 instead of 14?
14.5 would round to 15
14.4999 would round to 14
My code is working unless the number after the decimal is 5. Here's a screenshot I took of me stepping through the code.
You can see that it is reading a number from a cell on a worksheet into a variable called Average. That number is 14.5. It is then rounding that number and putting the new number into another variable called RoundedAverage. But in this case, RoundedAverage should be 15 (shouldn't it?), but instead it is 14. I cannot figure out why.
I tried making both Average and RoundedAverage into type Double, but that made no difference.
Any idea how I can make this work so that the result is 15 instead of 14?