News for hackers. Stuff that matters.
Re:A Bit Overcomplicated by AnIdiotOnTheNet on Thursday August 05, 2021 @04:26PM (#28079267)
> That's fair. A point that I didn't see mentionned is that what seems really easy for you may not be for others. I know about boolean logic, and bits, but I'm not comfortable with bitwise operation and they certainly don't seem obvious to me.

....how in the world can that be? Bitwise operations are just the application of boolean logic to each pair of bits in the arguments. If you know what "exclusive or" means, XOR should be perfectly comfortable to you no matter how many bits are involved.

Re:A Bit Overcomplicated by Zababa on Thursday August 05, 2021 @04:54PM (#28079661)
XOR is fine, I understand how it works, though I often don't think about it in some leetcode-type exercise where a xor is the "clever" solution. Byteshift is not really intuitive to me, for example in the article, I wouldn't know if I had to shift left or right and would take a bit of time to look that up. As I said, different people think in a different way. I don't understand how people that can understand for loops don't understand map and filter, but I know that they exist.
Re:A Bit Overcomplicated by AnIdiotOnTheNet on Thursday August 05, 2021 @06:05PM (#28080599)
That's just wild to me. If I held up a card with a decimal number on it and asked you to remove the X least significant digits, would you have to look up which way to shift them?
Re:A Bit Overcomplicated by Zababa on Thursday August 05, 2021 @06:14PM (#28080709)
Yes, I would have to.
Re:A Bit Overcomplicated by wtallis on Thursday August 05, 2021 @10:57PM (#28082804)
Would you have to consult a reference in order to be able to point to the least significant digit of a number written down in front of you? Maybe the "least significant/most significant" terminology is unfamiliar enough to you to present a stumbling block. Certainly the fact that you're communicating on a written forum means you're probably comfortable and experienced reading a string of digits and knowing how to understand it as representing a quantity, even if you've forgotten the formal terminology describing that process.
Re:A Bit Overcomplicated by Zababa on Friday August 06, 2021 @01:38AM (#28083684)
No, I wouldn't have to consult a reference. What's unfamiliar to me is how exactly byteshifting allows you to take the X most significant bits from a number, although now that I've talked a bit and thought a bit about this it starts to make more sense. The thing is, I've never spent much time thinking about this, so it's unfamiliar to me.
Re:A Bit Overcomplicated by dalmo3 on Thursday August 05, 2021 @07:55PM (#28081592)
If you have a number base n, shift right/left k digits means, respectively, "divide/multiply by n^k".

That's the same whether it's decimal (n=10) or binary (n=2).

Re:A Bit Overcomplicated by pcthrowaway on Thursday August 05, 2021 @09:59PM (#28082456)
It's floor division with bit shifting though, right?