You are on page 1of 6

Lab 2.

BINARY INTEGER REPRESENTATION. NORMAL


VALUES.
A binary (radix 2), integer, unsigned, n-bit number is written as:
n 1

N bn 1 ...b1b0 bi 2 i

(1)

i 0

where: N is the number value


bi are the n bits (BIT = Binary digiT , rom: cifr binar)
bn is the MSB = Most Significant Bit (rom: cel mai
semnificativ bit)
b0 is the LSB = Least Significant Bit (rom: cel mai puin
semnificativ bit)
The binary dot (or comma) is supposed, by default, on the right side
of LSB (integer number).
The normal binary unsigned representation is often used:
n

A 0, a1 a 2 ...a n 1 a n ai 2 i

(2)

i 1

where: A[0,1) is the normal binary number


ai are the n bits
a1 is the MSB
an is the LSB
The binary dot (or comma) is supposed, by default, on the left side
of MSB (fractional number).
In electronic circuits, the bits are transmitted either parallel
(simultaneous in time, on separate electric lines), or serial (sequentially in
time, on the same electric line). Regardless the transmission mode, the dot
position information is not encoded. The dot position is supposed fix,
1

Data Conversion and Acquisition Systems - Lab Manual


established by the used convention. (There are floating point
representations, in mantissa + exponent format, unusual in D/A and A/D
conversion, and which are not considered in this work). The same bit string
can be seen as an integer (as in (1)) or fractional (normal) number (as in
(2)). For bn-i = ai i=1...n, the two representations are tied by:
N 2n A

(3)

That is because, changing from A to N supposes binary dot


movement over n positions, meaning multiplication by n-th power of the
radix (2).
For bipolar (signed) number representation, an additional bit (sign
bit) is needed. Several bipolar codes are currently used, shown in table 1.
Based on an unsigned (unipolar) 3 bit code, the fourth (sign) bit was added.
Preferably, the sign bit is 0 for + sign, and 1 for sign (BO
code is an exception). This way, positive numbers are similar (sign bit read
as an meaningless 0) to the same value in the unsigned code.
SM Code (Signed Magnitude) (rom: MS = Mrime i Semn), splits
the bit string in two distinct fields: sign (MSB) and absolute value (all the
other bits). Two numbers, of opposite signs but same absolute value, have
complementary sign bits, and all the other bits identical.
1sC code (1s Complement) (rom: C1 = Complement fa de 1) has
positive numbers identical to SM ones. A negative number is the bit-by-bit
complement of the positive same absolute value number.
SM and 1sC codes have distinct representations for 0, respective
+0.
BO code (Binary Offset) (rom. BD = Binar Deplasat) assigns a
single representation for 0 and +0. It is built by sliding half-the-way the
binary unipolar n+1 bit code (4 bit in the example), such a way that the
middle point of the table (100...00), to correspond to the 0 value.
2sC code (2s complement) (rom: C2 = complement fa de 2), the
most used one, has the sign bit complemented compared to BO.
BO and 2sC use a single representation for 0 value (regardless the
sign), the freed bit combination is assigned to 2n value, not available for
2

Binary integer representation. Normal values


SM and 1sC codes. No bipolar code can write +2n on n+1 bits, as no
unipolar code can write it on n bits.
Signed
Unipolar
Value
magnitude
code
(SM)
8

7
111
0111
6
110
0110
5
101
0101
4
100
0100
3
011
0011
2
010
0010
1
001
0001
0
000
0000
-0

1000
-1

1001
-2

1010
-3

1011
-4

1100
-5

1101
-6

1110
-7

1111
-8

1s
2s
Binary offset
complement
complement
(BO)
(1s C)
(2s C)

0111
1111
0111
0110
1110
0110
0101
1101
0101
0100
1100
0100
0011
1011
0011
0010
1010
0010
0001
1001
0001
0000
1000
0000
1111

1110
0111
1111
1101
0110
1110
1100
0101
1101
1011
0100
1100
1010
0011
1011
1001
0010
1010
1000
0001
1001

0000
1000

Table 1. Bipolar binary codes

Data Conversion and Acquisition Systems - Lab Manual


LAB PURPOSE
The lab intends to familiarize the students to several types of binary
integer codes. The working software acts as a calculator showing
simultaneously the desired value as:
decimal number
binary number
- signed magnitude (SM) code;
- 1s complement (1s C) code;
- binary offset (BO) code;
- 2s complement (2 C) code;
hexadecimal number, corresponding to 2s complement binary code.
Either of these representations can act as value INPUT, selected by
pressing the associate button. The input value is translated in all the other
available codes.
For decimal or hexadecimal input values, the edit field can be selected using
the mouse or Tab-key. Enter-key or click outside the edit field confirms the
value. For user convenience, in binary representations, each bit is direcly
accessible using the mouse. Fig. 1 shows the lab software user interface.
THE NUMBER OF USED BITS
For binary codes, the representation number of bits is essential. It
can be chosen (for all the binary representations) using the control button,
and includes the sign bit. The available range is 1 32 (allowing integer
numbers between [-232; +232 1]). The sign bit (MSB) is shown in different
color (to emphase its different meaning).

Binary integer representation. Normal values

Fig. 1 The user interface.


For binary input data, the program only allows using the selected
number of bits.
However, for decimal or hexadecimal input data, if the selected
number of bits is to small, the binary values are correctly displayed, using
the minimum number of bits. The additional needed bits are shadowed,
and visual (and eventually acoustic) alarm is generated.
SM and 1s C codes generate different bit patterns for +0 and 0. To
emphasize this, if the input value is 0, the two alternative patterns are
displayed alternatively.

Data Conversion and Acquisition Systems - Lab Manual


The HELP button opens a window that shortly describes the
conversion algorithms for the considered integer codes.
THE LAB FLOW:
Analyzing each binary integer bipolar code, discussing the specific
advantages and disadvantages;
Studying the basic conversion steps from each code to each other pay
attention to the building of each code;
Understanding the meaning of normal values;
Identifying fast, simplified conversion algorithms from each code to
each other;
Practicing the previous found algorithms, verifying the results with the
program generated values.
Evaluating the earned knowledge running the TEST command. The test
supposes performing in a limited time interval (30 min.) the random
generated conversion requests. All possible code pairs (source destination)
are scanned in a random sequence, using random values. Each answer is
marked (true or false). After the allocated time, or after the last answer, the
program grades the test on a 1 to 10 scale. The Abandon button allows
quitting the test at any time (returning to the main program).

You might also like