I found following code in one of the frameworks we are using,
if (nValue + 0.01 > nLimit)
nValue = nValue - 0.01;
if (((nValue+1) / (int)(nValue+1)) == 1)
sprintf(szValue, "%0.0f", nValue);
else
sprintf(szValue, "%0.2f", nValue);
what is the meaning of this code
I’d suspect that the first part is a mistaken attempt to ensure nValue does not exceed nLimit. It possibly should be
In other words, if nValue is closer than 0.01 to the limit make it 0.01 less than the limit
To explain how the second part works, it involves dividing a floating point number by the integer part of the number. If the number is an integer then the result will be 1
e.g.
Adding 1 to each side is (as ufukgun noticed) to prevent devide by zero, but the devision is redundant as you could simply compare the float with the int