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

The Archive Base Latest Questions

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

I have 10 bytes – 4 bytes of low order, 4 bytes of high

  • 0

I have 10 bytes – 4 bytes of low order, 4 bytes of high order, 2 bytes of highest order – that I need to convert to an unsigned long. I’ve tried a couple different methods but neither of them worked:

Try #1:

var id = BitConverter.ToUInt64(buffer, 0);

Try #2:

var id = GetID(buffer, 0);

long GetID(byte[] buffer, int startIndex)
        {
            var lowOrderUnitId = BitConverter.ToUInt32(buffer, startIndex);
            var highOrderUnitId = BitConverter.ToUInt32(buffer, startIndex + 4);
            var highestOrderUnitId = BitConverter.ToUInt16(buffer, startIndex + 8);
            return lowOrderUnitId + (highOrderUnitId * 100000000) + (highestOrderUnitId * 10000000000000000);
        }

Any help would be appreciated, thanks!

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

    As the comments indicate, 10 bytes will not fit in a long (which is a 64-bit data type – 8 bytes). However, you could use a decimal (which is 128-bits wide – 16 bytes):

    var lowOrderUnitId = BitConverter.ToUInt32(buffer, startIndex);
    var highOrderUnitId = BitConverter.ToUInt32(buffer, startIndex + 4);
    var highestOrderUnitId = BitConverter.ToUInt16(buffer, startIndex + 8);
    
    decimal n = highestOrderUnitId;
    n *= UInt32.MaxValue;
    n += highOrderUnitId;
    n *= UInt32.MaxValue;
    n += lowOrderUnitId;
    

    I’ve not actually tested this, but I think it will work…

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

Sidebar

Related Questions

I have two bytes and I am setting different bits in order to get
I have a bin file that I need to convert to a byte array.
I have a byte array that may or may not have null bytes at
I have a 2884765579 bytes file. This is double checked with this function, that
I have an array of bytes in my C# class, and need to persist
I have two bytes that are made up of two 4-bit numbers packed together.
I am trying to convert an int into three bytes representing that int (big
I need to perform a bitwise equality between two bytes. That means that for
Let's say I have array of bytes: byte[] arr = new byte[] { 0,
I have an array of bytes and i want to determine if the contents

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.