power of two

    0

    0

    Mansimar Anand

    Check if number is power of two

    bool isPowerOfTwo(int num) {
    	if (num == 0) {
    		return false;
    	}
    	return ceil(log2(num)) == floor(log2(num));
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.