24-bit int
Patrick Schluter via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Sep 3 04:32:37 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:
big endian is indeed problematic.
> @property
> int value(int x) {
> _payload = (cast(ubyte*)&x)[0..3];
> return value;
> }
>
will not work on big endian machine.
version(BigEndian)
_payload = (cast(ubyte*)&x)[1..4];
More information about the Digitalmars-d-learn
mailing list