As 22.6 fits well within the precision of a var
That is not the case and the root of the problem here. The closest you can get to 22.6 with a 22.10 fixed point type (i.e. var) is 22.599609375, that is in binary form 10110.1001100110. (Calculated very fast on a piece of paper, may not be precise)
But 22.6 fits very well within a float, resulting in binary form to 01000001101101001100110011001101 or in a human readable form it is 2^4 * 1.4125.
In general if you have a number in decimal format with only few after decimal places you cannot draw any conclusions on the after decimal places of the binary representation of that number in fixed format.
while(gv_dist<22.6){
gv_dist=minv(gv_dist+time_step, 22.6);
}
If you have a look at the body of the loop 22.6 is interpreted as a float constant, hence it has to be casted to fixed so that minv can accept is as a parameter. In this conversion the float constant looses precision and becomes 22.599609375. So the maximum minv can now return and the maximum gv_dist can reach is exactly that number, 22.599609375. Hence the comparison in the while loops condition can never become true and the loop will never terminate.