Float to int is ALWAYS the floor value ie 2.3 = 2... 2.9 = 2 2.000001 = 2 and 2.99999999999 = 2.
You may want tio use the function ceil()... But I don't know if you have it in mikroC... ceil() returns the number rounded up... floor() returns a number rounded down.
Or you can use round() if it has it, but the standard way is to add 0.5 before the implicit floor() conversion. This way 2.0000001 to 2.499999 will still give you 2, but 2.5 to 2.9999 to 3.49 will give you 3.
ETA: obviously doesn´t work for negative numbers, you need to substract 0.5 there.
Yes but for 2.0001 ceil will give you 3 which is obviously not correct. If you add the 0.5 or -0.5 for negative numbers first you will get a properly rounded result just with the implicit floor conversion.
If you prefer. I just thought the goal was to add or subtract 0.5 from the float vlaue to round it.
Generally I would do that, and the data type conversion elsewhere as that is really part of the display function. But then I guess so is the round() operation...