# 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.

Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
what does nano mean?
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
absolutely yes
Daniel
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
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
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
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
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
where are the solutions?
where are the solutions?