Cannot understand why this code work but this not
Your problem is that you are doing integer maths.

mr = (130-20)/(1023-205)


reduces to:

mr = 110/818


Which normally equates to:

mr = 0.135


But since all those numbers are integers the result is an integer, and is truncated at the decimal point, which means that mr is assigned:

mr = 0


You can force floating point maths by either including a decimal point in one of the numbers, or adding the suffux f:

mr = (130-20)/(1023-205.0)


or

mr = (130-20)/(1023-205f)


Or casting a portion of the sum to a float as your other code does.