What is bitwise?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

What is bitwise?

jakeembx
Hi all, could anyone explain to me what bitwise is please? I have no idea what it is and I have searched online about it but can't find anything about it and I'm struggling to do the ALU part of the course without it! Thank you :)
Reply | Threaded
Open this post in threaded view
|

Re: What is bitwise?

cadet1620
Administrator
Bit-wise means one bit at a time. For example, bit-wise And means that each bit position in the operands is treated independently, i.e., like the And16 you built in chapter 1.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: What is bitwise?

jakeembx
Thank you for your reply, I understand it a bit better now. I know it may be a silly question but why it is used?, I don't understand why
Reply | Threaded
Open this post in threaded view
|

Re: What is bitwise?

ybakos
A basic case is for boolean logic. Other cases include bitmasks and a variety of other "clever" use cases. Can you look online to discover more?
Reply | Threaded
Open this post in threaded view
|

Re: What is bitwise?

ybakos
In reply to this post by jakeembx
In other words, bitwise negation is logical negation (!) while arithmetic negation is, well, arithmetic negation (-).
Reply | Threaded
Open this post in threaded view
|

Re: What is bitwise?

jakeembx
thank you for replying! I don't get the difference between normal AND and bitwise AND?
Reply | Threaded
Open this post in threaded view
|

Re: What is bitwise?

ybakos
For Hack, you can think of them as being the same.