What happens when you logical not a float?

后端 未结 3 2101
死守一世寂寞
死守一世寂寞 2020-12-10 10:35

I assume this just returns an int. Is there anything else going on I should be aware of? C/C++ differences?

float a = 2.5;
!a; // What does this return? Int?         


        
3条回答
  •  旧时难觅i
    2020-12-10 11:16

    See for yourself:

    #include 
    
    int main()
    {
       float a = 2.5;
    
       if ( !a )
           std::cout << !a << "\n";
    
       else
           std::cout << !a << "\n";
    }
    

提交回复
热议问题