Why typecasting not working properly in c# ?

I want to do a calculation which seems to be like

float addvalue,currentpostion;
int currentrowvalue;

void Start
{
addvalue = 2.1;
currentposition = ((addvalue- 0.3f)/0.6f)+5;
currentrowvalue = (int)currentposition;
Debug.Log("currentrowvalue " +currentrowvalue+ " currentposition " + currentposition);
}

Its working fine for all other value of addvalue i have supply 0.9,0.3 in every condition it work fine but for 2.1 i am getting following output

currentrowvalue 7 currentposition 8

why typecasting not working properly what mistake iam making ?

Doing a simple cast to int truncates a float. Because your result is probably something like 7.999999, (int)7.999999 will be 7.

To round a float to int, you should use Mathf.Round instead.

Use Mathf.RoundToInt instead

currentposition = ((addvalue - 0.3f) / 0.6f) + 5f;
currentrowvalue = Mathf.RoundToInt(currentposition);