NVIDIA

  www.nvidia.com
Work in HR? Unlock Free Profile

NVIDIA Senior Hardware Verification Engineer Interview Question

I interviewed in Santa Clara, CA and was asked:
"Describe a function to check if an integer is a power of 2."
Add Tags [?]
Answer

Part of a Senior Hardware Verification Engineer Interview Review - one of 465 NVIDIA Interview Reviews

Answers & Comments

7
of 8
votes
For an integer n:

If n is less than 1, return false.
If the bitwise & of n and n-1 is 0, return true.
Otherwise, return false.
- Interview Candidate on Jan 29, 2010
2
of 2
votes
Write the number in binary and count the number of ones in that.If the number os ones is only 1 then it the number is indeed a power of 2
- Jo on Jul 26, 2011
0
of 0
votes
first check if no is 1 then return false else write the number in binary and then check number of ones in that.if only one 1 is there then its a power of 2
- Anonymous on Jul 26, 2011

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.