Bit fields are currently going through the DIP process, although because
of ImportC having it, its just a matter of turning them on and adding
the parser stuff.
However there is a major drawback to it and is why you'll still need to
use a struct and that is you can't take a pointer to it.
On Sat, Mar 16, 2024 at 09:16:51PM +, Liam McGillivray via
Digitalmars-d-learn wrote:
> On Friday, 15 March 2024 at 00:21:42 UTC, H. S. Teoh wrote:
[...]
> > When dealing with units of data smaller than a byte, you generally
> > need to do it manually, because memory is not addressable by
> >
On Friday, 15 March 2024 at 17:25:09 UTC, Daniel N wrote:
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray
wrote:
I am in need of a data type for holding direction information;
one of 8 directions on a single axis. They are named in terms
of compass directions. If D had a 4-bit
On Friday, 15 March 2024 at 00:21:42 UTC, H. S. Teoh wrote:
On Thu, Mar 14, 2024 at 11:39:33PM +, Liam McGillivray via
Digitalmars-d-learn wrote: [...]
I tried to rework the functions to use bitwise operations, but
it was difficult to figure out the correct logic. I decided
that it's not
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray wrote:
I am in need of a data type for holding direction information;
one of 8 directions on a single axis. They are named in terms
of compass directions. If D had a 4-bit datatype, I would just
use this and do `+=2` whenever I want
On Thu, Mar 14, 2024 at 11:39:33PM +, Liam McGillivray via
Digitalmars-d-learn wrote:
[...]
> I tried to rework the functions to use bitwise operations, but it was
> difficult to figure out the correct logic. I decided that it's not
> worth the hassle, so I just changed the value storage from
On Friday, 15 March 2024 at 00:00:01 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 15/03/2024 12:47 PM, Basile B. wrote:
On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray
wrote:
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki)
Andrew Cattermole wrote:
[...]
I tried
On 15/03/2024 12:47 PM, Basile B. wrote:
On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray wrote:
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki) Andrew
Cattermole wrote:
[...]
I tried to rework the functions to use bitwise operations, but it was
difficult to figure
On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray
wrote:
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki)
Andrew Cattermole wrote:
[...]
I tried to rework the functions to use bitwise operations, but
it was difficult to figure out the correct logic. I decided
that it's
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki)
Andrew Cattermole wrote:
The cost of an add + increment then a bitwise and is only 2-4
cycles on a Haswell cpu. Depending upon if its working solely
in registers (via inlining) or its operating on ram.
Whereas if you need to do
There appears to be a few things that you may not be aware of based upon
this implementation.
The cost of an add + increment then a bitwise and is only 2-4 cycles on
a Haswell cpu. Depending upon if its working solely in registers (via
inlining) or its operating on ram.
The cost of a move
On Tuesday, 12 March 2024 at 06:38:28 UTC, Richard (Rikki) Andrew
Cattermole wrote:
By taking advantage of integer wrapping and a bitwise and, its
quite a simple problem to solve!
Challenge for the reader: add support for binary operations and
toString support.
Last night I pushed the
On Wednesday, 13 March 2024 at 10:27:49 UTC, Basile B. wrote:
The semantics of the operators are actually not as clear as
that. What if you define
```d
enum Direction
{
N = 1, NE, S = 45, SW
}
```
?
Certainly! EnumMembers; can be used. The EnumMembers template
from the std.traits
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray wrote:
I am in need of a data type for holding direction information;
one of 8 directions on a single axis. They are named in terms
of compass directions. If D had a 4-bit datatype, I would just
use this and do `+=2` whenever I want
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray wrote:
Perhaps this would be a good programming challenge for someone
more experienced than me. Make a data type (probably a struct)
for holding one of 8 directional values using 3 bits. It should
accept the use of increment operators
On 13/03/2024 11:00 AM, Liam McGillivray wrote:
I'm not familiar with the syntax of the line |value &= 7;|. Is it
equivalent to writing |value = value % 7;|?
& is a bitwise and.
LSB 123456789 MSB
& 7
LSB 12300 MSB
Anyway, you used an int, but I used an array of 3 bools. I'm guessing
On Tuesday, 12 March 2024 at 06:38:28 UTC, Richard (Rikki) Andrew
Cattermole wrote:
By taking advantage of integer wrapping and a bitwise and, its
quite a simple problem to solve!
Challenge for the reader: add support for binary operations and
toString support.
By taking advantage of integer wrapping and a bitwise and, its quite a
simple problem to solve!
Challenge for the reader: add support for binary operations and toString
support.
https://dlang.org/spec/operatoroverloading.html
```d
struct Direction {
private int value;
Direction
18 matches
Mail list logo