User:Saul/cs and math

From Organic Design wiki
< User:Saul
Revision as of 01:34, 3 August 2019 by Saul (talk | contribs) (Binary types.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Bases

Binary

Unsigned

In unsigned binary all numbers are positive.
Here is a few conversions from decimal to binary:

Binary : Decimal
000 : 0
001 : 1
010 : 2
011 : 3
100 : 4
101 : 5
110 : 6
111 : 7

One's Compliment

One's compliment was an old way of specifying signed binary.

The way of specifying a number as negative in binary was to set the most significant bit (The left most bit) to a 1.
0XXX would be a positive number and 1XXX would be a negative number.

In one's compliment negative numbers are represented by setting the most significant bit (The left most bit) and flipping all the other individual bits to the opposite.
For example to get -2 in binary:

010 (+2 in decimal)
-> 110 (Set the most significant bit to 1)
-> 101 (flip all other bits, -2 in decimal)

Here is a few conversions from decimal to binary (one's compliment):

Binary : Decimal
1000 : -7
1001 : -6
1010 : -5
1011 : -4
1100 : -3
1101 : -2
1110 : -1
1111 : -0
0000 : +0
0001 : +1
0010 : +2
0011 : +3
0100 : +4
0101 : +5
0110 : +6
0111 : +7

Two's Compliment