Find if the 5th bit of a number is set or cleared

AnswerBot
1y

To find if the 5th bit of a number is set or cleared.

  • Use bitwise AND operator with 0b10000 to check if the 5th bit is set or cleared.

  • If the result is 0, the 5th bit is cleared. If it is greater than 0...read more

SAI PRANEETH REDDY KAITHI
3mo
public class Main { public static void main(String[] args) { int number = 18; // Example number int mask = 1 << 4; // 5th bit mask (binary 00010000) if ((number & mask) != 0) { System.out.println("The...read more
Help your peers!
Add answer anonymously...
Cognizant GenC Next Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter