Re: byte and short data types use cases

2023-06-09 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 9 June 2023 at 15:07:54 UTC, Murloc wrote: On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: If you have four ubyte variables in a struct and then an array of them, then you are getting optimal memory usage. Is this some

Re: byte and short data types use cases

2023-06-09 Thread Ali Çehreli via Digitalmars-d-learn
On 6/9/23 08:07, Murloc wrote: > Where can I read more about this? I had written something related: http://ddili.org/ders/d.en/memory.html#ix_memory..offsetof The .offsetof appears at that point. The printObjectLayout() function example there attempts to visualize the layout of the members

Re: byte and short data types use cases

2023-06-09 Thread Basile B. via Digitalmars-d-learn
On Friday, 9 June 2023 at 15:07:54 UTC, Murloc wrote: On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: If you have four ubyte variables in a struct and then an array of them, then you are getting optimal memory usage. Is this some

Re: byte and short data types use cases

2023-06-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 09, 2023 at 11:24:38AM +, Murloc via Digitalmars-d-learn wrote: [...] > Which raised another question: since objects of types smaller than > `int` are promoted to `int` to use integer arithmetic on them anyway, > is there any point in using anything of integer type less than `int` >

Re: byte and short data types use cases

2023-06-09 Thread Murloc via Digitalmars-d-learn
On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: If you have four ubyte variables in a struct and then an array of them, then you are getting optimal memory usage. Is this some kind of property? Where can I read more about this? S

Re: byte and short data types use cases

2023-06-09 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: Hi, I was interested why, for example, `byte` and `short` literals do not have their own unique suffixes (like `L` for `long` or `u` for `unsigned int` literals) and found the following explanation: - "I guess short literal is not supporte

byte and short data types use cases

2023-06-09 Thread Murloc via Digitalmars-d-learn
Hi, I was interested why, for example, `byte` and `short` literals do not have their own unique suffixes (like `L` for `long` or `u` for `unsigned int` literals) and found the following explanation: - "I guess short literal is not supported solely due to the fact that anything less than `int`