binary arithmetic Flashcards

(4 cards)

1
Q

Binary addition

A
0+0=0
0+1=1
1+0=1
1 + 1 = 0 with carry
Carry + 0 + 0 = 1
Carry + 0 + 1 = 0 with carry
Carry + 1 + 0 = 0 with carry
Carry + 1 + 1 = 1 with carry
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Binary Subtract

A
0−0=0
0 − 1 = 1 with a borrow
1−0=1
1−1=0
0 − 0 − borrow = 1 with a borrow
0 − 1 − borrow = 0 with a borrow
1 − 0 − borrow = 0
1 − 1 − borrow = 1 with a borrow
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Binary multiplication

A

like with decimal, but with shifting the result every time and having an addition of the partial results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Modulo-N counters

A

Number sequences starting from zero to MAX_VALUE:
0 .. 1..2..Nmax-1.. 0 .. 1.. 2 and then again starting from zero. (like transaction log id):

cntr = (cntr + 1 ) % n;
cntr = (cntr + 1) & 0x3f;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly