Is number power of 2?

This is a discussion on Is number power of 2? within the C Programming forums, part of the General Programming Boards category; How do I decide whether a number( ranging from 8 bit to 32 bit) is power of two? I know ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    175

    Is number power of 2?

    How do I decide whether a number( ranging from 8 bit to 32 bit) is power of two? I know that any number which is power of 2 contain only one bit set.

    I want to test the condition in only one C statement. Any idea??/

    Let me know

  2. #2
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    hello, internet!

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    175
    Thanks...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. checking if a number if a power of 2
    By -EquinoX- in forum C Programming
    Replies: 10
    Last Post: 03-27-2009, 02:55 AM
  2. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 07:38 AM
  3. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  4. parsing a number
    By juancardenas in forum C Programming
    Replies: 1
    Last Post: 02-19-2003, 12:10 PM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 04:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21