I tried the ceil(x) function, but for some reason when x in already
round, it rounds it up to x+1
No that would mean that the implementation of ceil
was defective. Not impossible but extremely unlikely.
It's likely that the x
for which this effect is observed is in fact not integral, and the decimal portion is omitted from the formatting or debugger.
Assuming IEEE754, the closest double
to 1.1 is slightly larger than that; this most likely accounts for your result.
In your case, given that op_grade
is in fact a whole number, your best bet is to use an int
for op_grade
, and multiply by 11 instead; the subsequent rounding checks are then both trivial and exact.