Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:13:44+00:00 2026-06-18T11:13:44+00:00

I am trying to get the correct int out of an array of bytes.

  • 0

I am trying to get the correct int out of an array of bytes.
The bytes is read from a RFIDTag via POS for .Net.
(Acctually I need 18 bits)

In binary the byte array is as follows:
00001110 11011100 00000000 00011011 10000000

What I need to get out of it is:
00 00000000 11101101
(int = 237)

From the original bytes that would be the following bits in reverse order:
——10 11011100 00000000

I have been looking at bitArray. Array.Reverse. And several ways of shifting bits. But I just can’t wrap my head around this one.

Can anyone point me in the correct direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:13:46+00:00Added an answer on June 18, 2026 at 11:13 am

    You can get the bits and reverse them like this:

    byte[] data = { 0x0E, 0xDC, 0x00, 0x1B, 0x80 };
    
    // get only first four bytes
    byte[] bits = new byte[4];
    Array.Copy(data, 0, bits, 0, 4);
    
    // reverse array if system uses little endian
    if (BitConverter.IsLittleEndian) {
      Array.Reverse(bits);
    }
    
    // get a 32 bit integer from the four bytes
    int n = BitConverter.ToInt32(bits, 0); // 0x0EDC001B
    
    // isolate the 18 bits by shifting and anding
    n >>= 8; // 0x000EDC00
    n &= 0x0003FFFF; // 0x0002DC00
    
    // reverse by shifting bits out to the right and in from the left
    int result = 0;
    for (int i = 0; i < 18; i++) {
      result = (result << 1) + (n & 1);
      n >>= 1;
    }
    
    Console.WriteLine(result);
    

    Output:

    237
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get my program to read a value from a particular
I need help figuring out the correct data type for an assignment from a
I'm trying to write this code using mostly arrays. I'm trying to get Correct
I'm trying to get a sequence of things to happen in the correct order,
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I'm trying to get this validation for a date entered, from Jan 01 1901
I am trying to get data from the db in the response object and
I am trying to get images out of my /res folder dynamically and I
I am trying to get some information out of a database and then using
I have some Objective-C++ code that I'm trying to get events out of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.