answersLogoWhite

0


Best Answer

sol 1:
return(if(x!=0)&&!(x&(x-1));
sol 2:
return(if(x!=0)&&(x&(~x+)));

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a function using bitwise opetators to check whether an integer is a power of 2 or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which Bit wise operator is used to determine whether a particular bit is on or off?

Bitwise OR [|] operator


Write a program in vb to check whether a no is prime or not?

Function isPrime(ByVal n As Integer) As Boolean If n < 2 Then Return False End If Dim sqrtn As Integer = Math.Sqrt(n) + 1 For i As Integer = 2 To sqrtn If (n Mod i) = 0 Then Return False End If Next Return True End Function


Is 8.5 an integer?

No, -8.5 is not an integer. An integer is a number without any fractions.


What is the integer of 6.51 plus 1.35 plus 15.46?

Do the addition, then convert to an integer. The result will depend on whether you want to round to the nearest integer, round up, or round down.


What stament is always trueabout the sum of a negtive integer and positive integer?

The statement is: "Their sum is always an integer." Whether the sum is negative or positive depends on the two original integers.


Is 177 a square number?

If your question is whether or not 177 has a square root which is an integer, then no.


How do you know whether a is a multiple of another?

Divide the other into a. If the answer is an integer, a is a multiple of the other.


How can I tell whether a number is odd?

it is odd if when you divide it by 2 you do not get a whole integer


What is a function that determines whether a condition is true or false?

A logical function, such as the IF function.


What are all of the integer numbers?

All of the numbers that are in Positive and Negative sign are Integers , whether they reach 1 million if it has Positive or Negative sign it is considered as Integer .


What does the math term parity mean?

Parity refers to whether an integer is odd or even.


Are irrational numbers negative integers?

No. Every integer, whether negative or positive, is rational.