Is it safe when compare 2 float/double directly in Java?

后端 未结 9 961
刺人心
刺人心 2020-12-17 02:30

Is it safe if I use comparision like this (a is int, b and c is float/double):

a == b
b == c

It may hear ridiculous, but in my old programi

9条回答
  •  有刺的猬
    2020-12-17 02:52

    In java you can compare a float with another float,and a double with another double.And you will get true when comparing a double with a float when their precision is equal

提交回复
热议问题