0

How to create an integer whose binary representation is : 000...01101110
So the first three bits from left are 0 and right most 8 bits are given
one way I can think of is declaring an integer like int k =0b000....01101110;
What are other ways which could be used to declare an int like this?

4
  • 2
    What's wrong with the one way that you know? Why do you need more ways than that? Commented Jul 10, 2021 at 5:09
  • If you wish to work with binary numbers, I would recommend storing them in arrays. Commented Jul 10, 2021 at 5:10
  • You can use bit shifting and masking. It's not clear what you're trying to accomplish. Where do the middle bits with ... come from? Commented Jul 10, 2021 at 5:12
  • The value of an int is irrelevant for the declaration. Please decide what you want do with your int: output, init, read from user... Commented Jul 10, 2021 at 5:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.