24-bit int
    Nicholas Wilson via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Sep  1 17:43:00 PDT 2017
    
    
  
On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote:
> On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta 
> wrote:
>> Is there a way to create a 24-bit int? One that for all 
>> practical purposes acts as such? This is for 24-bit stuff like 
>> audio. It would respect endianness, allow for arrays int24[] 
>> that work properly, etc.
>
> I haven't looked at endianness beyond it working on my 
> computer. If you have special needs in that regard, consider 
> this a starting point:
>
>
> struct int24 {
>     ubyte[3] _payload;
>
>     this(int x) {
>         value = x;
>     }
>
>     ...
> }
>
> --
>   Biotronic
You may also want to put an align(1) on it so that you dont waste 
25% of the allocated memory in an array of int24's
    
    
More information about the Digitalmars-d-learn
mailing list