Back

Conference Topic:

Create a 16 bit binary number with a binary point somewhere in the string of bits.

Multiply (or divide) the number by one of the following:

* Decimal 4
* Decimal 8
* Decimal 16

Response:

Theresa L. Ford on 03-22-2004

```Calculate 69.2812510 * 410
using a 16 bit signed number with a
fixed binary point after the 11th bit.

1. Analysis of data format.

Position:   15   14   13   12  11  10   9  8  7  6  5   4    3     2      1       0
Value:    Sign  512  256  128  64  32  16  8  4  2  1  .5  .25  .125  .0625  .03125

Minimum value: -1023.9687510
Maximum value:  1023.9687510

2. Convert decimal to binary.

2.A. 69.2812510 = ?2

Value:    Sign  512  256  128  64  32  16  8  4  2  1  .5  .25  .125  .0625  .03125
0    0    0    0   1   0   0  0  1  0  1   0    1     0      0       1

69.2812510 = 0001000101.010012   # Sign bit temporarily removed.

OR:

Split 69.28125 into whole number ( 69 ) and fraction ( .28125 ).

Convert whole number to binary.

69 / 2 = 34 R 1
34 / 2 = 17 R 0
17 / 2 =  8 R 1
8 / 2 =  4 R 0
4 / 2 =  2 R 0
2 / 2 =  1 R 0
1 / 2 =  0 R 1

Read remainder from end to beginning ( 1000101 ).
Pad left with zeros to 10 bits.  ( 0001000101 ).

6910 = 00010001012

Convert fraction to binary.

.28125 * 2 = 0.5625
.5625  * 2 = 1.125
.125   * 2 = 0.25
.25    * 2 = 0.5
.5     * 2 = 1

Read whole number from beginning to end ( .01001 ).
Pad right with zeros to 5 bits ( .01001 ).

.2812510 = .010012

Combine binary whole number with binary fraction.

6910       = 00010001012
.2812510 =            010012

69.2812510 = 0001000101.010012

2.B. 410 = ?2

410 = 0000000000001002   # Sign bit temporarily removed.

3. Multiply 0001000101.010012 * 0000000000001002

Bit shift left 2 places ( 22 = 410 ).

0001000101.010012  << 210 = 0100010101.001002

No overflow.
Include sign.
positive number * positive number = positive number
sign of first number + sign of second number = sign of result (no carry)
0 + 0 = 0

00001000101.010012 * 00000000000001002 = 00100010101.001002

OR:

Standard Multiplication

0001000101.010012
x            1002  # Trimmed leading 0's on 410
0000000000000002   # Multiply by 0
0000000000000002    # Multiply by 0
+ 0001000101010012     # Multiply by 1
000100010101.001002   # Include decimal point
0100010101.001002   # Truncate to 15 bits, Overflow 0
00100010101.001002   # Include sign ( 0 + 0 )

00001000101.010012 * 00000000000.001002 = 00100010101.001002

OR:

Booth's Algorithm

0001000101.010012
x           1002  # Trimmed leading 0's on 410
+ 0001000101010012     # Skip zeros, multiply by 1
000100010101.001002   # Include decimal point
0100010101.001002   # Truncate to 15 bits, Overflow 0
00100010101.001002   # Include sign ( 0 + 0 )

00001000101.010012 * 00000000000.001002 = 00100010101.001002

3. Check (convert answer to decimal).

00001000101.010012 * 00000000000.001002 = 00100010101.001002

Value:    Sign  512  256  128  64  32  16  8  4  2  1  .5  .25  .125  .0625  .03125
0    0    1    0   0   0   1  0  1  0  1   0    0     1      0       0

25610 + 1610 + 410 + 110 + .12510 = 277.125

4. Summary.

00001000101.010012       69.28125
x  00000000000001002      x       4
00100010101.001002        277.125

```

Back