24-bit int

Biotronic via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 2 02:59:11 PDT 2017


On Saturday, 2 September 2017 at 00:43:00 UTC, Nicholas Wilson 
wrote:
> On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote:
>> struct int24 {
>>     ubyte[3] _payload;
>>
>>     this(int x) {
>>         value = x;
>>     }
>>
>>     ...
>> }
>
> 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

The very first test in my code checks this:

     int24[3] a;
     assert(a.sizeof == 9);

On the other hand, using Mir's well-tested code instead of 
something I hacked together in 10 minutes is probably a good idea.

--
   Biotronic


More information about the Digitalmars-d-learn mailing list