Float vs Double

后端 未结 7 1830
-上瘾入骨i
-上瘾入骨i 2021-01-17 23:56

Is there ever a case where a comparison (equals()) between two floating point values would return false if you compare them as DOUBLE

相关标签:
7条回答
  • 2021-01-18 00:21

    You should be okay to make that cast as long as the equality test involves a delta.

    For example: abs((double) floatVal1 - (double) floatVal2) < .000001 should work.

    Edit in response to the question change

    No you would not. The above still stands.

    0 讨论(0)
提交回复
热议问题