[DiscordArchive] So to get like the first 8?
[DiscordArchive] So to get like the first 8?
Archived author: Kavligula • Posted: 2018-06-03T21:06:59.577000+00:00
Original source
This is an example of how to get specific bits out of an integer
Archived author: Kavligula • Posted: 2018-06-03T21:07:01.947000+00:00
Original source
I *think*
Archived author: Skarn • Posted: 2018-06-03T21:08:16.896000+00:00
Original source
the question now is how to construct those masks dynamically
Archived author: Skarn • Posted: 2018-06-03T21:08:24.380000+00:00
Original source
when given different n_bits
Archived author: Kavligula • Posted: 2018-06-03T21:08:40.456000+00:00
Original source
It'd just be multiplying some value by the size of n_bits
Archived author: Kavligula • Posted: 2018-06-03T21:09:37.345000+00:00
Original source
In the example you listed they're just using size_t
Archived author: Kavligula • Posted: 2018-06-03T21:09:45.439000+00:00
Original source
Which is defined depending on the architecture iirc
Archived author: Kavligula • Posted: 2018-06-03T21:09:54.484000+00:00
Original source
schlumpf would have a better idea of that, I don't do much bit manipulation anymore
Archived author: schlumpf • Posted: 2018-06-03T21:12:00.051000+00:00
Original source
def mask(bits):
r = 0
while bits:
r = r | 1
r = r << 1
bits -= 1
return r
mask(1)=0b1
mask2)=0b11
Archived author: schlumpf • Posted: 2018-06-03T21:15:36.498000+00:00
Original source
A = (raw & mask(bitsa)) >> 0
B = (raw & (mask(bitsb) << bitsa)) >> (bitsa)
sign = (raw & (mask(1) << (bitsa+bitsb)) >> (bitsa+bitsb)