Re: 24-bit int

2017-09-03 Thread Ilya via Digitalmars-d-learn
On Sunday, 3 September 2017 at 23:30:43 UTC, EntangledQuanta wrote: On Sunday, 3 September 2017 at 04:01:34 UTC, Ilya Yaroshenko wrote: On Saturday, 2 September 2017 at 03:29:20 UTC, EntangledQuanta wrote: On Saturday, 2 September 2017 at 02:49:41 UTC, Ilya Yaroshenko wrote: [...] Thanks. Se

Re: 24-bit int

2017-09-03 Thread EntangledQuanta via Digitalmars-d-learn
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

Re: 24-bit int

2017-09-03 Thread Patrick Schluter via Digitalmars-d-learn
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

Re: 24-bit int

2017-09-02 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 2 September 2017 at 03:29:20 UTC, EntangledQuanta wrote: 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

Re: 24-bit int

2017-09-02 Thread solidstate1991 via Digitalmars-d-learn
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. If you need to

Re: 24-bit int

2017-09-02 Thread Biotronic via Digitalmars-d-learn
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

Re: 24-bit int

2017-09-02 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 2 September 2017 at 07:20:07 UTC, kinke wrote: struct int24 { ubyte[3] _payload; } static assert(int24.sizeof == 3); static assert(int24.alignof == 1); Making absolute sense. ubytes don't need any specific alignment to be read efficiently. Yes, that does make sense. It does

Re: 24-bit int

2017-09-02 Thread kinke via Digitalmars-d-learn
On Saturday, 2 September 2017 at 02:37:08 UTC, Mike Parker wrote: It's not a bug, but a feature. Data structure alignment is important for efficient reads, so several languages (D, C, C++, Ada, and more) will automatically pad structs so that they can maintain specific byte alignments. On a 32-

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Saturday, 2 September 2017 at 02:37:08 UTC, Mike Parker wrote: On Saturday, 2 September 2017 at 01:19:52 UTC, EntangledQuanta wrote: The whole point is so that there is no wasted space, so if it requires that then it's not a waste of space but a bug. Audio that is in24 is 3 bytes per samp

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
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

Re: 24-bit int

2017-09-01 Thread Ilya Yaroshenko via Digitalmars-d-learn
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

Re: 24-bit int

2017-09-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 2 September 2017 at 01:19:52 UTC, EntangledQuanta wrote: The whole point is so that there is no wasted space, so if it requires that then it's not a waste of space but a bug. Audio that is in24 is 3 bytes per sample, not 4. Every 3 bytes are a sample, not every 3 out of 4. Bas

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
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: 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

Re: 24-bit int

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
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

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: [...] 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: [...] Thanks,

Re: 24-bit int

2017-09-01 Thread Biotronic via Digitalmars-d-learn
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 look

24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
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.