Write a one line code to compare the two integer numbers using bitwise operator.

28 Dec 2022 Balmiki Mandal 0 C Programming

Learn how to compare integer numbers using bitwise operators in C

To compare two integer numbers using bitwise operator in C and return a boolean value (1 for true and 0 for false), you can use the following one line code:

int isEqual = (num1 ^ num2) == 0;

where num1 and num2 are the two integer numbers being compared, and ^ is the bitwise XOR operator. This code compares the two numbers bitwise and returns 1 if they are equal, and 0 otherwise.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.