Changed inv variables to floats to avoid int rounding.