从整数的复合除法返回 Double

Returning Double from compound division of Integers

我正在尝试从这个 int 部门 return double。我读过 this question 但我似乎无法让它适用于这种特殊情况:

yComponent +=
        ((Math.min(i.getObservedIndividuals(), ii.getObservedIndividuals()))/
        Math.max(i.getObservedIndividuals(), ii.getObservedIndividuals())*
        i.getObservedIndividuals())/
        (parent.getShareableSpecies()*
        match.getTotalObservedIndividuals());

yComponentdouble,其他都是 int

yComponent +=
    ((Math.min(i.getObservedIndividuals(), ii.getObservedIndividuals())) /
    (double) Math.max(i.getObservedIndividuals(), ii.getObservedIndividuals())*
    i.getObservedIndividuals()) /
    (double) (parent.getShareableSpecies()*
    match.getTotalObservedIndividuals());

如果您不将至少一个操作数转换为双精度或浮点数,除法将不会使用 "float processor"(算术处理器)。这意味着 3 / 2 = 1 对于 CPU,但是 3 / 2f = 1.5f