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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:50:14+00:00 2026-05-26T23:50:14+00:00

I am making application in C# which has a byte array containing hex values.

  • 0

I am making application in C# which has a byte array containing hex values.

I am getting data as a big-endian but I want it as a little-endian and I am using Bitconverter.toInt32 method for converting that value to integer.

My problem is that before converting the value, I have to copy that 4 byte data into temporary array from source byte array and then reverse that temporary byte array.

I can’t reverse source array because it also contains other data.

Because of that my application becomes slow.

In the code I have one source array of byte as waveData[] which contains a lot of data.

byte[] tempForTimestamp=new byte[4];
tempForTimestamp[0] = waveData[290];
tempForTimestamp[1] = waveData[289];
tempForTimestamp[2] = waveData[288];
tempForTimestamp[3] = waveData[287];
int number = BitConverter.ToInt32(tempForTimestamp, 0);

Is there any other method for that conversion?

  • 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-26T23:50:14+00:00Added an answer on May 26, 2026 at 11:50 pm

    If you know the data is big-endian, perhaps just do it manually:

    int value = (buffer[i++] << 24) | (buffer[i++] << 16)
              | (buffer[i++] << 8) | buffer[i++];
    

    this will work reliably on any CPU, too. Note i is your current offset into the buffer.

    Another approach would be to shuffle the array:

    byte tmp = buffer[i+3];
    buffer[i+3] = buffer[i];
    buffer[i] = tmp;
    tmp = buffer[i+2];
    buffer[i+2] = buffer[i+1];
    buffer[i+1] = tmp;
    int value = BitConverter.ToInt32(buffer, i);
    i += 4;
    

    I find the first immensely more readable, and there are no branches / complex code, so it should work pretty fast too. The second could also run into problems on some platforms (where the CPU is already running big-endian).

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

Sidebar

Related Questions

I am making an application which has j2me in client side and dotnet on
I am making an iPhone Application which has a list of RSS Feeds, and
I'm making a simple quiz application which has multiple questions. It has no back
hi all: making a sample application in which we can store data on File
I'm making a web application for a customer that has clients who want to
I am making an iphone application which has user information on a web server.
I'm making a very simple application which has to perform an action when the
I am making application in which i want to find the list of the
I am making an application that has Activity which communicates with a single service,
I am making an application which is a user interface to access 2 types

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.