<
justin_smith>
marijnfs: I'd usually use "1 << N" to create the operand, then use ^ to xor the two
<
Gliptic>
if it's a [32]u8, you need to compute which byte as well
<
marijnfs>
ok then I need logic to find the right u8 and work with that
<
ifreund>
you could consider checking out std.PackedIntArray()
<
marijnfs>
that sounds interesting
<
ifreund>
though I don't know how well it'll map to whatever else you are doing
<
marijnfs>
although in general I like the simplicity of [32]u8
<
marijnfs>
yeah I also make an AutoHashMap with it e.g.
<
marijnfs>
probably starts to get annoying
<
justin_smith>
marijnfs: to find the byte for a given bit offset, you could use "N >> 3"
<
justin_smith>
then "N & 7" to find the offset in that byte - I thin
<
justin_smith>
but maybe PackedIntArray is easier
<
ifreund>
you can also cast to the PackedIntArray and back if you want of course
<
marijnfs>
justin_smith: yeah i'm using / and % 256 for now;)
<
marijnfs>
but he doesn't like my shift
<
marijnfs>
: LHS of shift must be a fixed-width integer type, or RHS must be compile-time known
<
marijnfs>
id[byte_id] = id[byte_id] ^ (1 << bit_id);
<
marijnfs>
bit_id is a usize
<
Gliptic>
you need a specific type for that "1"
<
ifreund>
probably @as(u8, 1)
<
ifreund>
and bit_id would need to be a u3
<
marijnfs>
zig is picky
<
marijnfs>
ifreund: ok that worked, has to @intCast to u3.
<
ifreund>
can't just make it a u3?
<
Gliptic>
does zig understand that x & y becomes the narrower width integer of the two?
<
Gliptic>
if so, you'd think x & @as(u3, 7) would work
marijnfs has quit [Quit: WeeChat 2.8]
factormystic has quit [Read error: Connection reset by peer]
factormystic has joined #zig
jukan has joined #zig
<
kameliya[m]>
that'd be neat
jukan has quit [Ping timeout: 260 seconds]
factormystic has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
gazler has joined #zig
gazler_ has quit [Read error: Connection reset by peer]
mmkarakaya has joined #zig
kbd has joined #zig
leon-p has quit [Quit: leaving]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
notzmv has quit [Ping timeout: 246 seconds]
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig