Float numbers in Java

后端 未结 6 1655
傲寒
傲寒 2020-12-07 03:10

Could anyone please me why the output of the following programme is not \" different different\"?

public static void main(String[] args)
{

float f1=3.2f;
fl         


        
6条回答
  •  醉话见心
    2020-12-07 03:27

    Also, I think anything with a decimal defaults into a double, so when you do a comparison, you have to add 'f' as well like if(f2==6.4f).

提交回复
热议问题