0% found this document useful (0 votes)
103 views58 pages

02 Binary Codes

The document discusses binary codes and binary-coded decimal (BCD). It explains that binary codes are used to represent discrete elements of information digitally. BCD uses 4-bit codes to represent each decimal digit, with different bits representing the values 1, 2, 4, 8. Gray codes are also discussed, where each code differs from the next in only one bit, to avoid errors during transitions between codes. Examples of converting between decimal, binary, and BCD are provided.

Uploaded by

Dann Laurte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
103 views58 pages

02 Binary Codes

The document discusses binary codes and binary-coded decimal (BCD). It explains that binary codes are used to represent discrete elements of information digitally. BCD uses 4-bit codes to represent each decimal digit, with different bits representing the values 1, 2, 4, 8. Gray codes are also discussed, where each code differs from the next in only one bit, to avoid errors during transitions between codes. Examples of converting between decimal, binary, and BCD are provided.

Uploaded by

Dann Laurte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 58

BINARY CODES

SCHOOL OF COMPUTING RIEL A. GOMEZ


BINARY CODES

• Digital systems represent and


manipulate not only binary numbers,
but also many other discrete
elements of information (letters,
punctuation marks, etc).

• Any discrete element of information


that is distinct among a group of
quantities can be represented with a
binary code.

• The codes must be in binary because


only circuits that represent and
manipulate patterns of 0's and 1's can
be manufactured economically for
use in computers.

Binary Codes
BINARY-CODED DECIMAL (BCD)

• In the first chapter, it was shown how


decimal numbers were converted into
binary.

• Recall that each bit had a place value equal


to 2 raised to the position number. Thus the
binary number 10011 is equal to:
4 3 2 1 0

10011 = 1 × 244 + 1 × 211 + 1 × 200 = 19

• Numbers such as 10011 are referred to as


straight binary, pure binary, or natural
binary.

• It would be better or more natural if a


particular number of binary bits could
represent the numbers 0 to 9.

Binary Codes
BINARY-CODED DECIMAL (BCD)

• But this does not happen in pure


binary, a 3-bit binary number
represents the values 0 to 7 and a 4-
bit number represents 0 to 15.

• What is needed is a system where a


group of binary digits can represent
the decimal numbers 0-9, and the
next group 10-99 etc.

• With a BCD or Binary-Coded


Decimal code, a decimal number is
not converted as a whole to binary,
but rather digit by digit.

Binary Codes
BINARY-CODED DECIMAL (BCD)
• The Binary Coded Decimal (BCD) code is used for
representing the decimal digits 0 through 9.

• BCD uses four bits, with the weights equal to those of a 4-bit
binary integer (BCD)

Digit BCD Code Digit Decimal


Take note that
0 0000 5 0101 the binary
1 0001 6 0110 numbers 1010,
1011, 1100,
2 0010 7 0111 1101, 1110, and
1111 are not
3 0011 8 1000 used.
4 0100 9 1001

Binary Codes
BINARY-CODED DECIMAL (BCD)

• For example, convert 5810 into its BCD form:

5 8

0101 1000

Therefore, 5810 = 01011000BCD

• Take note that 5810 = 001110102 (in natural binary).

Binary Codes
BINARY-CODED DECIMAL (BCD)
• For example, convert 17410 into its BCD form:

1 7 4

0001 0111 0100

Therefore, 17410 = 000101110100BCD

• Take note that 17410 = 101011102 (in natural


binary). BCD may require more bits to represent
decimal numbers than natural binary.

Binary Codes
BINARY-CODED DECIMAL (BCD)

• As another example, convert 362.5710 into its


BDC form:

3 6 2 . 5 7

0011 0110 0010 0101 0111

362.5710 = 001101100010.01010111BCD

Binary Codes
BINARY-CODED DECIMAL (BCD)

• To convert 0110010101BCD to decimal:

00 01 1001 0101

1 9 5

Therefore, 0110010101BCD = 19510

Binary Codes
BINARY-CODED DECIMAL (BCD)

• It is important to realize that BCD numbers are


decimal numbers and not binary numbers,
although they use bits in their representation.

• The only difference between a decimal number and


BCD is that decimal are written with the symbols 0,
1, 2, 3, 4, 5, 6, 7, 8, and 9 and BCD numbers use the
binary code 0000, 0001, 0010, …, 1001.

• The decimal value is exactly the same.

Binary Codes
BCD ADDITION

• Adding BCD numbers simply involves adding the


bits used to represent them.

Examples:

410 = 0100BCD 210 = 0000


0010BCD
+ 310 = 0011BCD + 710 = 0111
0011BCD
710 = 0111BCD 910 = 1001
0111BCD

Binary Codes
BCD ADDITION

• However, if the sum of two BCD digits exceeds 9,


problems may occur.

Example:

410 = 0100BCD
+ 610 = 0110
0011BCD
1010 = 1010
0111BCD
BCD

0001 0000BCD invalid BCD code

Binary Codes
BCD ADDITION

• Problems also occur if the binary sum of the two


BCD digits resulted in a carry.

Example:

810 = 0100
1000BCD
BCD
+ 910 = 0011
1001BCD
BCD
1710 =10111
0001BCD
BCD

0001 0111BCD
1110

Binary Codes
BCD ADDITION

• In cases like these, simply add 610 (0110BCD) to the


sum to correct the results.

Examples:
410 = 0100BCD 810 = 0000
1000
BCDBCD
+ 610 = 0110
0011BCD + 910 = 0011
1001
BCDBCD
1010 = 1010
0111BCD
BCD 1710 = 10111
0001BCD
BCD
+ 0110BCD + 0110BCD
1 0000BCD 1 0111BCD
1010 1710

Binary Codes
EXERCISES

Convert each decimal number to BCD:

1. 6210
2. 2510
3. 27410
4. 28410
5. 42.9110
6. 5.01410

Binary Codes
EXERCISES

Convert each BCD number to decimal:

1. 1001BDC
2. 101BCD
3. 1100001BCD
4. 1000111BCD
5. 110110.1000BCD
6. 111000.10001BCD

Binary Codes
GRAY CODES

• A Gray Code is defined as a code


Decimal Binary Gray Code
0 0000 0000
where two consecutive 1 0001 0001
codewords differ in only one bit. 2 0010 0011
3 0011 0010

• In other words, only one bit 4


5
0100
0101
0110
0111
changes when going from one 6 0110 0101
number to the next. 7 0111 0100
8 1000 1100

• The Gray code is used in 9


10
1001
1010
1101
1111
applications in which the normal 11 1011 1110
sequence of binary numbers may 12 1100 1010
produce an error or ambiguity 13 1101 1011
during the transition from one 14 1110 1001
number to the next. 15 1111 1000

Binary Codes
GRAY CODES
• If binary numbers are used, a Decimal Binary Gray Code
0 0000 0000
change, for example, from 0111 1 0001 0001
to 1000 may produce an 2 0010 0011
intermediate erroneous number 3 0011 0010
1001 if the value of the rightmost 4 0100 0110
bit takes longer to change than do 5 0101 0111
the values of the other three bits . 6 0110 0101
7 0111 0100
8 1000 1100
0 1 1 1 9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011

1 0 0 1 14
15
1110
1111
1001
1100

Binary Codes
GRAY CODES
Decimal Binary Gray Code
• The Gray code eliminates this 0 0000 0000

problem, since only one bit 1 0001 0001

changes its value during any 2


3
0010
0011
0011
0010
transition between two 4 0100 0110
numbers. 5 0101 0111
6 0110 0101
7 0111 0100
0 1 1 1 8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010

0 1 0 1 13
14
1101
1110
1011
1001
15 1111 1100

Binary Codes
CONVERTING BINARY TO GRAY CODE
• Write the binary number completely.

9310 = 10111012

• Copy the most significant bit.


1 0 1 1 1 0 1

• Add the most significant bit to the next significant bit of the binary number. Disregard any carry
terms.
1 0 1 1 1 0 1
+
1 1

• Add the second significant bit to third significant bit, also disregard the carry, and so forth up to
the least significant bit.
1 0 1 1 1 0 1
+ + + + +
1 1 1 0 0 1 1

Binary Codes
CONVERTING GRAY CODE TO BINARY

• Write the Gray code number completely.

1110011GC

• Copy the most significant bit.


1 1 1 0 0 1 1

• Add the MSB of the binary number to the Gray code number in the next significant bit,
neglecting the carry terms that result.
1 1 1 0 0 1 1
+
1 01

• Continue step 3 until all Gray code bits have been used
1 1 1 0 0 1 1
+ + + + +
1 0 1 1 1 0 1

Binary Codes
GRAY CODES

• Exercises • Exercises

Convert the following Convert the following


numbers to their Gray Gray code numbers to
Code equivalent: their binary equivalent:

110101012 11010101GC

8F16 11110000GC

23410 01010101GC

Binary Codes
ASCII CODE

• Many applications of digital computers


required the handling not only of numbers, but
also of other characters or symbols such as the
letters of the alphabet.

• For instance, an enrollment system with


thousands of students will use a computer to
process its files.

• To represent the names and other pertinent


information, it is necessary to formulate a
binary code for the letters of the alphabet.

• In addition, the same binary code must


represent numerals and special characters
(such as $, +, and common punctuation marks).

Binary Codes
ASCII CODE
• An alphanumeric character set is a set of elements that includes the 10 decimal
digits. the 26 letters of the alphabet. and a number of special characters .

• Such a set contains between 64 and 128 elements if both uppercase and
lowercase letters are included.

• In this case, a binary code with seven bits will be needed.

• The standard binary code for the alphanumeric characters is the American
Standard Code for Information Interchange (ASCII ), which uses seven bits to
code 128 characters.

• The ASCII code also contains 94 graphic characters that can be printed and 34
non printing characters used for various control functions.

• The graphic characters consist of the 26 uppercase letters (A through Z). the 26
lowercase letters (a through z), the 10 numerals (0 through 9), and 32 special
printable characters, such as %, *, and $.

Binary Codes
ASCII CODE

• For example, the ASCII code for


the letter 'A' is:

A = 4116 = 010000012

• Take note ASCII is a seven-bit


code, but most computers
manipulate an eight-bit quantity
as a single unit (a byte).

• Therefore. ASCII characters


most often are stored one per
byte. The extra bit is oftentimes
made equal to 0.

• The extra bit may also be used


for other purposes such as error
detection (parity checking).

Binary Codes
ASCII CODE

• As mentioned earlier, the ASCII


code also contains 34 non-
printable control characters
(such as LF, DEL, ETC.)

• The control characters are used


for routing data and arranging
the printed text into a
prescribed format.

• There are three types of control


characters

1. format effectors
2. information separators
3. communication-control
characters.

Binary Codes
EXCESS-K REPRESENTATION
Unsigned Binary Decimal
• In unsigned binary using 4 bits, 0000 0
00002 is equivalent to 010 (the 0001 1
smallest unsigned integer) lowest 0010 2
while 11112 is equivalent to 0011 3
1510 (the highest unsigned 0100 4
integer that can be represented 0101 5
using 4 bits) 0110 6
0111 7
• Usually there is some hardware 1000 8
that could sort unsigned 1001 9
numbers, or at the very least, 1010 10
compare two unsigned integers 1011 11
and determine which number highest 1100 12
was larger, or if they were 1101 13
equal.
1110 14
1111 15

Binary Codes
EXCESS-K REPRESENTATION
2's C Binary Decimal
• Now recall the 2's complement 0000 0
representation. 0001 +1
0010 +2
• The one disadvantage of 2's complement is 0011 +3
that the numbers cannot be sorted.
0100 +4
highest
0101 +5
• The hardware that can sort or compare
unsigned numbers could not be used for 0110 +6
numbers in 2's complement. In particular, it 0111 +7
would say all negative values were larger 1000 -8
than non-negative values.
1001 -7
lowest 1010 -6
• This leads to another idea for signed number
representation in which the same ordering 1011 -5
where 0000 represents the smallest value 1100 -4
and 1111 represents the largest value is 1101 -3
kept.
1110 -2
1111 -1

Binary Codes
EXCESS-K REPRESENTATION

• Excess-k Representation is a digital coding scheme where


all-zero corresponds to the minimal negative value and all-
one to the maximal positive value.

• It is also known as Offset Binary, Excess Code, or Biased-k


Representation.

• An excess-k representation of a code c is formed by adding


the offset value k to each code word of c.

• There is no standard for offset binary, but most often the


offset k for an n-bit binary word is k = 2n−1.

Binary Codes
EXCESS-K REPRESENTATION
Decimal Excess-8
-8 0000

• For example, if n = 4 bits, the offset is -7 0001

24-1 = 23 = 8 (excess-8 representation). -6 0010


-5 0011
-4 0100
• This means that the excess-8 code for -3 0101

a decimal number is just the unsigned -2 0110

binary code of that number plus 8. -1 0111


0 1000
+1 1001
• This has the consequence that the +2 1010
"zero" value is represented by a 1 in +3 1011

the most significant bit and zero in all +4 1100

other bits. +5 1101


+6 1110
+7 1111

Binary Codes
EXCESS-K REPRESENTATION
Decimal Excess-8 2's C Binary
-8 0000 1000
-7 0001 1001
-6 0010 1010
-5 0011 1011
-4 0100 1100
• In general, the effect is -3 0101 1101
conveniently the same as -2 0110 1110
using two's complement -1 0111 1111
except that the most 0 1000 0000
significant bit is inverted. +1 1001 0001
+2 1010 0010
+3 1011 0011
+4 1100 0100
+5 1101 0101
+6 1110 0110
+7 1111 0111

Binary Codes
EXCESS-K REPRESENTATION

• In excess notation, two


parameters are specified: the Decimal Excess-5
number of bits, n, and the bias -5 000
value, k. -4 001
-3 010
011
• For example, let k = 5 and n = 3
-2
-1 100
bits. 0 101
+1 110
+2 111
This is excess-5 representation,
which assigns 000 to -5 and
makes 111 equal to +2.

Binary Codes
EXCESS-K REPRESENTATION

• In fact, excess-k representation maps n


0's to −k, and n 1's to −k + 2n – 1. Decimal Excess-5
-5 000

• For example, for excess-7 with 8 bits: -4 001


-3 010
-2 011
00000000 = –7 -1 100
11111111 = –7 + 28 – 1 = 248 0 101
+1 110
• If k = 2n – 1 is chosen, then the sign bit is +2 111
flipped, where 1 in the MSB means
positive, and 0 means negative.

Binary Codes
EXCESS-K REPRESENTATION

• To convert a decimal number to excess-k:

1. Add k to the decimal number.


2. Convert the resulting decimal number to unsigned binary using the required
number of bits.

Examples:

1. Convert +2 to excess-127 using 8 bits.

+2 + 127 = 129 = 100000012

2. Convert -5 to excess-8 using 4 bits.

-5 + 8 = 3 = 00112

Binary Codes
EXCESS-K REPRESENTATION

• To convert excess-k to a decimal number:

1. Convert the binary number to decimal using unsigned binary representation.


2. Subtract k from the decimal number.

Examples:

1. Convert 110001112 (excess-128) to decimal.

110001112 = 199
199 – 128 ==+71
+71

2. Convert 00112 (excess-4) to decimal.

00112 ==33
3 – 4 = =– –1 1

Binary Codes
EXCESS-K REPRESENTATION
• Exercises

Convert the following numbers to their excess-k binary


representation:

-610 to excess-7 (using 4 bits)


+11510 to excess-127 (using 8 bits)

Convert the following numbers to their excess-k binary


representation:

10002 excess-7
100000012 excess-127

Binary Codes
FLOATING-POINT NUMBERS

• The discussions so far considered only integers as


being represented in binary.

• Take note that integers have an implied binary


point at the right end of the number, just after bit
b 0.

b7 b6 b5 b4 b3 b2 b1 b0 .

implied binary point

Binary Codes
FLOATING-POINT NUMBERS

• If a full word in a 32-bit word length computer is


used to represent a signed integer in 2's-
complement representation, the range of values
that can be represented is

2(n-1) to +2 (n-1) − 1

−231 to +231 − 1

which is −2,147,483,648 to +2,147,483,647


roughly −10
(roughly 10 to
−2.15 101010to
× +10 ). +2.15 × 1010).

Binary Codes
FLOATING-POINT NUMBERS
b31 b30 b29 b28 b27 . . . b2 b1 b0 .
• It is also possible to assume that the binary point is just to
the right of the sign bit, thus representing a fraction.

b0 . b-1 b-2 b-3 . . . b-29 b-30 b-31

The smallest fraction that can be represented is therefore


2-31 = 4.66 × 10-10.

• Neither of these ranges is sufficient for scientific


calculations, which might involve parameters like
Avogadro’s number (6.0247 x 1023) or Planck’s constant
(6.6254 x 10-27).
BInary Codes
FLOATING-POINT NUMBERS

• A computer must be able to represent numbers and operate on


them in such a way that the position of the binary point is variable
and is automatically adjusted as computation proceeds.

• In this case, the binary point is said to float, and the numbers are
called floating-point numbers.

• This distinguishes them from fixed-point numbers, whose binary


point is always in the same position.

Floating Point:
.
The point moves left or right according to an exponent value.

BInary Codes
FLOATING-POINT NUMBERS
• In the decimal scientific notation, numbers may be written
as 6.0246 x 1023, 6.6254 x 10-27, −1.0341 x 102, −7.3000 x
10-14, and so on.

These numbers are said to be given five significant digits.

The scale factors (1023, 10-27, and so on) indicate the


position of the decimal point with respect to the significant
digits.

• A floating-point representation is one in which a number is


represented by its sign, a string of significant digits,
commonly called the significand or mantissa, and an
exponent to an implied base for the scale factor.

Binary Codes
FLOATING-POINT NUMBERS

• In general, the floating-point form of a number N is written


as:

N = S × rE

where S is the significand, a fixed-point number containing


the significant digits of N; and E is the exponent, a fixed-
point integer.

Take note that r is the radix of the floating-point number.

Decimal numbers use radix of 10 (S × 10E); while binary


numbers use radix of 2 (S × 2E).

Binary Codes
FLOATING-POINT NUMBERS

• Representation of floating point number is not unique. For


example, the number 55.66 can be represented as:

55.66 × 100
5.566 × 101 The exponent increases if
the decimal point is
0.5566 × 102 moved to the left and
556.6 × 10-1 vice-versa.

The same is true for binary floating-point numbers. The number


10110.110 can be represented as:

10110.110 × 20
10.110110 × 23
1011011.0 × 2-2

Binary Codes
FLOATING-POINT NUMBERS

• In a digital system, it is useful to have one unique representation


for each number.

• A floating-point number is normalized if the exponent is adjusted


so that there is only a single non-zero digit before the radix point.

• Examples of normalized floating-point numbers:


‒ 6.4293 × 105
‒ 1.00111 × 2−3
• Examples of floating-point numbers that are not normalized:
‒ 24.7891 × 10−4
‒ 0.00101 × 22

Binary Codes
FLOATING-POINT NUMBERS

• A floating-point number can be normalized by simply adjusting the


position of the decimal (or binary) point and adjusting the
exponent.

• For example:

1. The decimal number 0.054321 can be normalized as:

0.054321 × 100 = 5.4321 × 10–2

2. The binary number 1010.1011 × 22 can be normalized as:

1010.1011 × 22 ×= 21.0101011
3. × 25

Binary Codes
FLOATING-POINT NUMBERS

• It is also important to note


that floating number
arithmetic is very much less
efficient than integer
arithmetic.

• Hence, programmers should


use integers if the application
does not require floating-
point numbers.

• It could be speed up with a


dedicated floating-point co-
processor.

Binary Codes
FLOATING-POINT NUMBERS

• In computers, floating-point numbers are


represented in scientific notation of fraction
(F) and exponent (E) with a radix of 2, in the
form of 1.F × 2E.

• Modern computers adopt IEEE 754 standard


for representing floating-point numbers.

• There are two representation schemes: 32-


bit single-precision and 64-bit double-
precision.
Binary Codes
FLOATING-POINT NUMBERS

• IEEE-754 32-bit Single-Precision Floating-Point Numbers

In the 32-bit single-precision floating-point representation:

a) The most significant bit is the sign bit (S), with 0 for positive numbers
and 1 for negative numbers.
b) The following 8 bits represent exponent (E) using the excess-127
format.
c) The remaining 23 bits represents the fraction (F). The actual significand
is normalized with an implicit leading 1 in the form of 1.F.

Binary Codes
FLOATING-POINT NUMBERS

Exponent Exponent in Actual Exponent


(Binary) Decimal (E') (E)
• Since the exponent E is 00000000 0 -127
expressed in excess-127 00000001 1 -126
format using 8 bits, the 00000010 2 -125
value actually stored in . . .
the exponent field E' is in
the range: . . .
. . .
0 ≤ E' ≤ 255 01111111 127 0
10000000 128 +1
10000001 129 +2
and the actual exponent
is expressed as . . .
. . .
. . .
E = E' – 127
11111101 253 +126
11111110 254 +127
11111111 255 +128

Binary Codes
FLOATING-POINT NUMBERS
• However, the end values
of E', namely, 0 and 255, Exponent Exponent in Actual Exponent
are not used to represent (Binary) Decimal (E') (E)
exponents. 00000000 0 number
-127 is 0
00000001 1 -126
Instead, these are used to 00000010 2 -125
indicate floating-point . . .
values of exact 0 and . . .
infinity, respectively.
. . .
01111111 127 0
• This means that the
actual exponent, E, is in 10000000 128 +1
the range –126 ≤ E ≤ 127. 10000001 129 +2
. . .
• The excess–k . . .
representation for . . .
exponents enables 11111101 253 +126
efficient comparison of 11111110 254 +127
the relative sizes of two 11111111 255 number
+128 is ∞
floating-point numbers.

Binary Codes
FLOATING-POINT NUMBERS

• As an example, find the decimal equivalent of the floating point


binary number represented by 1100 0000 1011 0000 0000 0000
0000 00002.

1100 0000 1011 0000 0000 0000 0000 0000

S=1
E = 10000001
F = 01100000000000000000000

The actual significand is normalized with an implicit leading 1 in the


form of 1.F. In this example, the actual significand is:

1.01100000000000000000000

Binary Codes
FLOATING-POINT NUMBERS
Since S = 1, this represents a negative number.

The exponent of the number is E = 10000001. This is equivalent to


12910 in unsigned binary.

However, since the exponent follows the excess-127 format, the


actual value of the exponent is 129 – 127 = 2.

The floating-point number is actually:


2 1 0 –1

– 1.01100000000000000000000 × 22 ==––101.1
101.1

• Hence, the decimal number represented is:

– (1 × 22 + 0 × 21 + 1 × 20 + 1 × 2-1) = – 5.510.

Binary Codes
FLOATING-POINT NUMBERS

• As another example, find the decimal equivalent of the floating


point binary number represented by 0100 0010 0000 1011 1001
0000 0000 00002.

0100 0010 0000 1011 1001 0000 0000 0000

S=0
E = 10000100
F = 00010111001000000000000

The actual significand is:

1.00010111001000000000000

Binary Codes
FLOATING-POINT NUMBERS

Since S = 0, the number is positive.

The exponent of the number is E = 10000100. This is equivalent to


The actual
132 10. The actual value
value of
of the
the exponent
exponent isis 132
132 –– 127
127 == 5.
5.

So the floating-point number is actually:


5 4 3 2 1 0 –1 –2 –3 –4 –5 –6

+ 1.00010111001000000000000 × 25 = + 100010.111001

Hence, the decimal number represented is:

+ (1 × 25 + 1 × 21 + 1 × 2-1 + 1 × 2-2 + 1 × 2-3 + 1 × 2-6)


= + 34.89062510.

Binary Codes
FLOATING-POINT NUMBERS
• To convert the decimal number 0.101562510 to the 32-bit floating-
point binary representation.

The first step is to convert the number to binary:

0. 1015625 × 2 = 0.203125 integer = 0 MSB


0.203125 × 2 = 0.40625 integer = 0
0.40625 × 2 = 0.8125 integer = 0
0.8125 × 2 = 1.625 integer = 1
0.625 × 2 = 1.25 integer = 1
0.25 × 2 = 0.5 integer = 0
0.5 × 2 = 1.0 integer = 1 LSB

0.101562510 = 0.00011012

Binary Codes
FLOATING-POINT NUMBERS

Normalize the binary number 0.00011012.

0.0001101 × 20 = 1.101 × 2-4–4

The fraction F is therefore 10100000000000000000000.

The exponent is –4 + 127 = 123 = 01111011

The number is positive (S = 0) so the 32-bit floating-point


representation of 0.101562510 :

0011 1101 1101 0000 0000 0000 0000 0000

Binary Codes
FLOATING-POINT NUMBERS
• Exercises

Convert the following floating-point numbers to decimal:

110000101010110010000000000000002
BF40000016

Convert the following decimal numbers to their floating-


point representation (express your answer in hexadecimal
format):

10.62510
–0.7510

Binary Codes
FLOATING-POINT NUMBERS

• IEEE-754 64-bit Double-Precision Floating-Point Numbers

In the 64-bit single-precision floating-point representation:

a) The most significant bit is the sign bit (S), with 0 for positive numbers
and 1 for negative numbers.
b) The following 11 bits represent exponent (E) using the excess-1023
format.
c) The remaining 52 bits represents the fraction (F). The actual significand
is normalized with an implicit leading 1 in the form of 1.F.

Binary Codes

You might also like