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 4054634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:36:02+00:00 2026-05-20T14:36:02+00:00

I have been given the following programming task (edited to obscure mission-specifics): The raw

  • 0

I have been given the following programming task (edited to obscure mission-specifics):

The raw (binary) file (needed for Phase II implementation) can be interrogated to detect if pods are present. Format is dependent on the source of the file – FormatX vs. FormatY. Using a wordsize of 16 bits, the following bit masks can be used to determine presence of pods from the file:

Word #  Mask    Value   Indicates
1       0xFF00  0x8700  Little Endian (Format X)
1       0x00FF  0x0087  Big Endian (Format Y)
13      0x0200  0x0200  right pod installed (Format X)
13      0x0002  0x0002  right pod installed (Format Y)
13      0x0100  0x0100  left pod installed (Format X)
13      0x0001  0x0001  left pod installed (Format Y)

How I have approached this problem so far: I have the file on my local file system, so I use System.IO.File.OpenRead to get it into a Stream object. I want to read through the stream 16 bits/2 bytes at a time. For the first “word” of this size, I try applying bitmasks to detect what format I am dealing with. Then I skip forward to the 13th “word” and based on that format, detect right/left pods.

Here’s some preliminary code I have written that is not working. I know the file I am reading should be Format Y but my check is not working.

int chunksRead = 0;
int readByte;
while ((readByte = stream.ReadByte()) >= 0)
{
    chunksRead++;

    if (chunksRead == 1)
    {
        // Get format
        bool isFormatY = (readByte & 0x00FF) == 0x0087;
    }
    else if (chunksRead == 13)
    {
        // Check pods
    }
    else if (chunksRead > 13)
    {
        break;
    }
}

Can anyone see what’s wrong with my implementation? How should I account for the 2 byte wordsize?

Edit based on response from @Daniel Hilgarth
Thanks for the quick reply, Daniel. I made a change and it’s working for the first word, now:

byte[] rawBytes = new byte[stream.Length];
stream.Read(rawBytes, 0, rawBytes.Length);
ushort formatWord = Convert.ToUInt16(rawBytes[0] << 8 | rawBytes[1]);
bool formatCheck = (formatWord & 0x00FF) == 0x0087;

I just need to find an example file that should return a positive result for right/left pod installed to complete this task.

  • 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-05-20T14:36:02+00:00Added an answer on May 20, 2026 at 2:36 pm

    You are mixing bytes and words. The word at position 13 is about whether the left or the right pod is installed. You are reading 12 bytes to get to that position and you are checking the 13th byte. That is only half way.
    The same problem is with your format check. You should read the first word (=2 bytes) and check whether it is one of the desired values.

    To get a word from two bytes you read, you could use the bit shift operator <<:

    ushort yourWord = firstByte << 8 | secondByte;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been given the following request. Please give 7% of the current contacts
I have been given the task of adding functionality to an existing IIS 6.0
I have been given the unenviable task of cleaning up after a developer who
I have been given the following bit of code as an example: Make port
I've been given a task where I have to create a parser for a
I have been given the following: <div class=elf>Label 1</div> <div class=eff>Data 1</div> <div class=elf>Label
I have been given a task to crawl / parse and index available books
I am new to Qt , I have been given this task where i
I have this been given C code where the heading statement includes the following:
I have been given an array in the following format and need to put

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.