Get the most significant bit from an 8-bit value

tc90

I know there are similar questions on this site, however, I couldn't seem to find something that really helped me out with the issue i'm having.

So far:

I have 1-byte (8-bits) that could be any combination of 1's and 0's.

Ex: 11000010 is my byte of data. (Little-Endian)

What i need to do is determine if the Most Significant Bit (MSB), in this case the 11, is either a 00, 01, 10, 11 and from there do some other things.

I have so far gotten the program to output the Byte as 11000010 (stored in a string) and am trying to extract the 11 from it. (If i can figure that out then creating a switch case or if statement to check what the contents is simple enough on my own).

**I haven't been so good with C++ which is why i'm asking for assistance.

Any help is greatly appreciated.

Rok Jarc

It seemes that you want to get the value of first two most significant bits.

This can be done by filtering them out and moving the value 6 bits to the left:

unsigned char input;
unsigned char output;

input = whatever_you_want;

output = input & 0xc0; //0xc00 = 0b11000000
output = output >> 6;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get the most significant bit from an 8-bit value

From Dev

set most significant bit in C

From Dev

How can I get the value of the least significant bit in a number?

From Dev

How to clear most significant bit in byte?

From Dev

Find most significant set bit in a long

From Dev

Comparing the Most Significant Bit of two numbers: ==, <, <=

From Dev

how is the most significant bit radix sort more efficient than the least significant bit radix sort?

From Dev

Writing a bit reader in JAVA (32-bit little-endian most-to-least-significant bit packing)

From Dev

The MSB (most significant bit ) in pyserial python sent to arduino uno in damged

From Dev

How do I flip the most significant bit in MIPS?

From Dev

Xor starting with the significant bit

From Dev

Clearing least significant bit

From Dev

Least significant bit mips

From Dev

Fast way of finding most and least significant bit set in a 64-bit integer

From Dev

how do you get a negative decimal value from 8 bit signed binary number?

From Dev

Byte conversion from 32 bit to 8 bit

From Dev

Get mosts significant nibble, regardless of int bit length and endianness

From Dev

Fastest way to get last significant bit position in a ulong (C#)?

From Dev

How to get 8 byte pointer value on 64 bit machine on gdb?

From Dev

Calculating 16-bit integer value from two 8-bit integers?

From Dev

How to get 8 bit Colors?

From Dev

Get the bit which is most at the left with dichotomy

From Dev

Getting least significant bit in JavaScript

From Dev

Extraction of the least significant bit of a pixel

From Dev

compare 8bit value against 16bit value

From Dev

efficient way to convert 16 bit value to 8 bit value

From Dev

efficient way to convert 16 bit value to 8 bit value

From Dev

Create a mask that marks the most significant set bit, using only bitwise operators

From Dev

How to write a constant time function to copy the most significant bit to all bits

Related Related

  1. 1

    Get the most significant bit from an 8-bit value

  2. 2

    set most significant bit in C

  3. 3

    How can I get the value of the least significant bit in a number?

  4. 4

    How to clear most significant bit in byte?

  5. 5

    Find most significant set bit in a long

  6. 6

    Comparing the Most Significant Bit of two numbers: ==, <, <=

  7. 7

    how is the most significant bit radix sort more efficient than the least significant bit radix sort?

  8. 8

    Writing a bit reader in JAVA (32-bit little-endian most-to-least-significant bit packing)

  9. 9

    The MSB (most significant bit ) in pyserial python sent to arduino uno in damged

  10. 10

    How do I flip the most significant bit in MIPS?

  11. 11

    Xor starting with the significant bit

  12. 12

    Clearing least significant bit

  13. 13

    Least significant bit mips

  14. 14

    Fast way of finding most and least significant bit set in a 64-bit integer

  15. 15

    how do you get a negative decimal value from 8 bit signed binary number?

  16. 16

    Byte conversion from 32 bit to 8 bit

  17. 17

    Get mosts significant nibble, regardless of int bit length and endianness

  18. 18

    Fastest way to get last significant bit position in a ulong (C#)?

  19. 19

    How to get 8 byte pointer value on 64 bit machine on gdb?

  20. 20

    Calculating 16-bit integer value from two 8-bit integers?

  21. 21

    How to get 8 bit Colors?

  22. 22

    Get the bit which is most at the left with dichotomy

  23. 23

    Getting least significant bit in JavaScript

  24. 24

    Extraction of the least significant bit of a pixel

  25. 25

    compare 8bit value against 16bit value

  26. 26

    efficient way to convert 16 bit value to 8 bit value

  27. 27

    efficient way to convert 16 bit value to 8 bit value

  28. 28

    Create a mask that marks the most significant set bit, using only bitwise operators

  29. 29

    How to write a constant time function to copy the most significant bit to all bits

HotTag

Archive