Explanation for the basics of datatypes

Status
Not open for further replies.

patan.gova

Full Member level 3
Joined
Dec 19, 2011
Messages
172
Helped
4
Reputation
8
Reaction score
0
Trophy points
1,296
Visit site
Activity points
2,776
Hello,

I am new to the microcontrollers and want to know the working of the below two functions for the mutliplication of two 16bit numbers, if the 16bit microcontroller is used

Code:
Multilication function1
int32_t z; 
z=mutliplication ( 0x1234, 0x5678); 
return  z >> 15;

Multilication function2
signed long z;  
RESLO and RESHI =mutliplication ( 0x1234, 0x5678); //if results are stored in two different variables of 16bits(RESLO=lower,RESHI=higher)
z = RESHI;                          
z = (result<<16)|RESLO;             

Can someone explain me thw working of above lines.

thanks.
 

hello

this is my understanding ...

 

sorry,
I made a mistake while writing and it should be should 'z' instead of 'result' as this
signed long z;
RESLO and RESHI =mutliplication ( 0x1234, 0x5678); //if results are stored in two different variables of 16bits(RESLO=lower,RESHI=higher)
z = RESHI;
z = (z<<16)|RESLO;
 

And also which line says so "result of multiplication is divided by 2^15 (/ 32768)
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…