You need to cast int1
to a double
so the compiler know to use floating point calculations (instead of integer ones):
double ratio = ((double) int1) / int2;
To store the floating point calcualtion of ration * word1
in the UWORD
you need to cast it again (to prevent warnings):
UWORD word2 = (UWORD) (ratio * word1);
Note: this will chop off the decimals, if you need proper rounding try the round()
function, available from math.h
. (Again, with proper casting!)