Why does Decimal.Divide(int, int) work, but not (int / int)?

后端 未结 8 862
旧时难觅i
旧时难觅i 2020-12-08 03:18

How come dividing two 32 bit int numbers as ( int / int ) returns to me 0, but if I use Decimal.Divide() I get the correct answer? I\'m by no means

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 04:06

    If you are looking for 0 < a < 1 answer, int / int will not suffice. int / int does integer division. Try casting one of the int's to a double inside the operation.

提交回复
热议问题