24-bit int

EntangledQuanta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 1 20:29:20 PDT 2017


On Saturday, 2 September 2017 at 02:49:41 UTC, Ilya Yaroshenko 
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.
>
> Hi,
>
> Probably you are looking for bitpack ndslice topology:
> http://docs.algorithm.dlang.io/latest/mir_ndslice_topology.html#.bitpack
>
> sizediff_t[] data;
> // creates a packed signed integer slice with max allowed value 
> equal to `2^^24 - 1`.
> auto packs = data[].sliced.bitpack!24;
>
> packs has the same API as D arrays
>
> Package is Mir Algorithm
> http://code.dlang.org/packages/mir-algorithm
>
> Best,
> Ilya

Thanks. Seems useful.



More information about the Digitalmars-d-learn mailing list