I want a one line code to check whether a given integer is of form 2i – 2j or NOT. (using bitwise operators)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As AndreyT says, the answer can be found in Hacker’s Delight:
(was debating whether to post this, as it’s a homework question, but as AndreyT already mentioned it and it’s easily Googlable, I figure it’s more helpful to quote directly; I’ll let the questioner deal with the ethical implications of accepting help on the homework, and I expect that if his answer depends on this, he will write up the explanation of how it works himself)