Possible Loss of Fraction

后端 未结 5 1610
慢半拍i
慢半拍i 2020-12-02 14:12

Forgive me if this is a naïve question, however I am at a loss today.

I have a simple division calculation such as follows:

double returnValue = (myO         


        
5条回答
  •  醉话见心
    2020-12-02 14:27

    When you divide two int's into a floating point value the fraction portion is lost. If you cast one of the items to a float, you won't get this error.

    So for example turn 10 into a 10.0

    double returnValue = (myObject.Value / 10.0);
    

提交回复
热议问题