azurelunatic: Vivid pink Alaskan wild rose. (Default)
Azure Jane Lunatic (Azz) 🌺 ([personal profile] azurelunatic) wrote2003-04-16 09:34 pm

lookups...

2's complement
bitwise and
bitwise or
open in C++

Demland's freaking that we haven't been taught all of this shit.

[identity profile] yaksha42.livejournal.com 2003-04-16 09:49 pm (UTC)(link)
Ahh, something I learned in ECT. I'm assuming this is in binary, right? The shortcut for 2's compliment:

Reverse all the numbers in the binary string. I.E. change all the 1's to 0's and change the 0's to 1. Do this for all the numbers except that last one. So the 2's compliment of 1111 would be 0001. 0000 would be 1110. 1010 would be 0100 etc.

bitwise and is like a multiplication. So if you have 1100 bitwise and with 0110 you would get 0100. For the first digits, 0 times 0 = 0. The second, 1 times 1 = 1. 1 times 0 = 0. The last, 0 times 0 = 0. So the only way to end up with a 1 is to have two 1's in the same value location.

bitwise and is somewhat the opposite. You need a 1 in either of the two spots to get a 1. So 1100 bitwise or with 0110 would give you 1110. 1 with 1 gives you 1. 1 with 1 gives you 1. 0 with 1 gives you 1. 0 and 0 gives you 0.

[identity profile] boojum.livejournal.com 2003-04-16 10:09 pm (UTC)(link)
I know the first three (although I'd have to look up the exact mechanism for the first and what it makes easy again -- subtraction?), but what do you mean by the last? File manipulation?

Well...

[identity profile] popefelix.livejournal.com 2003-04-17 04:59 am (UTC)(link)
That's all really important stuff, but it's also really low-level.

open() in C++ should be a lot like open() in C, shouldn't it? Do a man 2 open.