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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:00:03+00:00 2026-06-11T18:00:03+00:00

I have a project that I am working on where I require a data

  • 0

I have a project that I am working on where I require a data type that doesn’t exist in the .NET BCL – an Unsigned Int24. For calculations that I am doing, the 4th byte in an int32, even when set to all zeroes, screws up my results.

EDIT:
I’m doing bitwise circular shifts on a 24bit integer space that is limited to only 24bits. If the rotation is performed at 24bit level on a 32bit number the result is wildly incorrect.

Does anyone know of any third party implementations of this data type that are available?

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-06-11T18:00:05+00:00Added an answer on June 11, 2026 at 6:00 pm

    Implementing Int24 isn’t hard (honest!). But we need to know more about why you need to implement it. @nneonneo wonders if you’re trying to interface with a native library that uses 24-bit integers. If that’s the case then you can be done by doing something like this:

    [StructLayout(LayoutKind.Sequential)]
    public struct UInt24 {
        private Byte _b0;
        private Byte _b1;
        private Byte _b2;
    
        public UInt24(UInt32 value) {
            _b0 = (byte)( (value      ) & 0xFF );
            _b1 = (byte)( (value >>  8) & 0xFF ); 
            _b2 = (byte)( (value >> 16) & 0xFF );
        }
    
        public unsafe Byte* Byte0 { get { return &_b0; } }
    
        public UInt32 Value { get { return _b0 | ( _b1 << 8 ) | ( _b2 << 16 ); } }
    }
    
    // Usage:
    
    [DllImport("foo.dll")]
    public static unsafe void SomeImportedFunction(byte* uint24Value);
    
    UInt24 uint24 = new UInt24( 123 );
    SomeImportedFunction( uint24.Byte0 );
    

    Modifying the class for big-endian or signed Int24 is an exercise left up to the reader.

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

Sidebar

Related Questions

I have a project that I'm working on that requires me to send data
I have a project that I am working on in django. There are a
Yes I have a project that I'm working on in NetBeans 7.1 and I
I have a working project that Im amending, it crashes after trying to use
I have a large-ish project that I'm working on which uses git as the
I have a django project that I have been working on as a solo
I have a small project that I will be working on shortly that collects
I have a console project that I have been working on. I added log4net
In a project that I am working on, I have the following entities: Analyst
On the project that I'm currently working I have a requirement to run a

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.