Ints and Doubles doing division

后端 未结 5 1857
挽巷
挽巷 2021-01-19 21:33

Short version: Why don\'t I have to coerce 60, and int, into a double, so that I can use division with another double if I DO care about the fractional part?

Long ve

5条回答
  •  北海茫月
    2021-01-19 21:41

    You are right. The int 60 is promoted to double automatically. Writing 60.0 is correct, but redundant.

    C# language specification, "7.2.6.2 Binary numeric promotions": http://msdn.microsoft.com/en-us/library/aa691330.aspx

提交回复
热议问题