Conditional check for “i == (2^8)” fails when i is 512?

后端 未结 6 1743
醉话见心
醉话见心 2021-01-04 00:41

Here is a small Program to print powers of 2 till 8. But it is not quitting after 8. Please explain the reason.

#include 
#include 

        
6条回答
  •  日久生厌
    2021-01-04 01:05

    For your edit Section

    #include 
    int main()
    {
            if((2^8) == (1<<8)) {
                    printf("True.. \n");
            } else {
                    printf("False..!!");
            }
            return 0;
    }
    

    It will return False.

提交回复
热议问题