# Fixed point arithmetic  (Page 4/4)

 Page 4 / 4

(Q format addition, subtraction): Perform the additions $01001101+11100100$ , and $01111001+10001011$ when the binary numbers are Q-7 format. Also compute $01001101-11100100$ and $10001011-00110111$ . In which cases, do you have overflow?

Intentionally left blank.

## Multiplication

Multiplication of two 2's complement numbers is a bit complicated because of the sign bit. Similar to themultiplication of two decimal fractional numbers, the result of multiplying twoQ- $N$ numbers is Q- $2N$ , meaning that we have $2N$ binary digits following the implied binary digit. However, depending on the numbers multiplied, theresult can have either 1 or 2 binary digits before the binary point. We call the digit right before the binarypoint the sign bit and the one proceeding the sign bit (if any) the extended sign bit .

The following is the two examples of binary fractional multiplications:

0.110 0.75 Q-3 X 1.110 -0.25 Q-3-------------------------- 00000110 01101010 -------------------------------1110100 -0.1875 Q-6

Above, all partial products are computed and represented in Q-6 format for summation. For example, 0.110*0.010 =0.01100 in Q-6 for the second partial product. For the 4th partial product, caremust be taken because in 0.110*1.000 , 1.000 represents $-1$ , so the product is -0.110 = 1.01000 (in Q-6 format) that is 2's complement of 0.11000 . As noticed in this example, it is important to represent eachpartial product in Q-6 (or in general Q- $2N$ ) format before adding them together. Another example makes this point clearer:

1.110 -0.25 Q-3 X 0.110 0.75 Q-3------------------------- 0000111110 111100000 -----------------------------11110100 -0.1875 Q-6

For the second partial product, we need 1.110*0.010 in Q-6 format. This is obtained as 1111100 in Q-6 (check!). A simple way to obtain it is to first perform themultiplication in normal fashion as 1110*0010 = 11100 ignoring the binary points, then perform sign extension by putting enough 1s (if the result is negative) or 0s (if the result isnonnegative), then put the binary point to obtain a Q-6 number. Also notice that we need to remove the extra signbit to obtain the final result.

In C62x, if we multiply two Q-15 numbers using one of multiply instruction (for example MPY ), we obtain 32 bit result in Q-30 format with 2 sign bits. To obtain the result back inQ-15 format, (i) first we remove 15 trailing bits and (ii) remove the extended sign bit.

(Q format multiplication): Perform the multiplications 01001101*11100100 , and 01111001*10001011 when the binary numbers are Q-7 format.

Intentionally left blank.

## Assembly language implementation

When A0 and A1 contain two 16-bit numbers in the Q-15 format, we can perform the multiplications using MPY followed by a right shift.

1 MPY .M1 A0,A1,A2 2 NOP3 SHR .S1 A2,15,A2 ;lower 16 bit contains result 4 ;in Q-15 format

Rather than throwing away the 15 LSBs of the multiplication result by shifting, you can round up the result by adding 0x4000 before shifting.

1 MPY .M1 A0,A1,A2 2 NOP3 ADDK .S1 4000h,A6 4 SHR .S1 A2,15,A2 ;lower 16 bit contains result5 ;in Q-15 format

## C language implementation

Let's suppose we have two 16-bit numbers in Q-15 format, stored in variable x and y as follows:

short x = 0x0011; /* 0.000518799 in decimal */ short y = 0xfe12; /* -0.015075684 in decimal */short z; /* variable to store x*y */

The product of x and y can be computed and stored in Q-15 format as follows:

z = (x * y) >> 15;

The result of x*y is a 32-bit word with 2 sign bits. Right shifting it by 15 bits ignores the last15 bits, and storing the shifted result in z that is a short variable (16 bit) removes the extended sign bit by taking only lower 16 bits.

#### Questions & Answers

how to know photocatalytic properties of tio2 nanoparticles...what to do now
it is a goid question and i want to know the answer as well
Maciej
Do somebody tell me a best nano engineering book for beginners?
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
what is the Synthesis, properties,and applications of carbon nano chemistry
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
so some one know about replacing silicon atom with phosphorous in semiconductors device?
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
for screen printed electrodes ?
SUYASH
What is lattice structure?
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
what is nano technology
what is system testing?
preparation of nanomaterial
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
what is system testing
what is the application of nanotechnology?
Stotaw
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
Azam
anybody can imagine what will be happen after 100 years from now in nano tech world
Prasenjit
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
Azam
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
Prasenjit
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
Damian
silver nanoparticles could handle the job?
Damian
not now but maybe in future only AgNP maybe any other nanomaterials
Azam
Hello
Uday
I'm interested in Nanotube
Uday
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
Prasenjit
can nanotechnology change the direction of the face of the world
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Berger describes sociologists as concerned with
where are the solutions?
where are the solutions?