AnsweredAssumed Answered

64 bit fixed point multiplication of two different input Q-formats

Question asked by Balakumar08 on Aug 11, 2015
Latest reply on Aug 21, 2015 by Harshit.Gaharwar

Hi to All,

 

     I am trying to do multiply two 64bit values using fixed point integer multiplication.  In the following method

 

static Fix64 operator *(Fix64 x, Fix64 y)

  
var xl = x.m_rawValue; // underlying long of x
  
var yl = y.m_rawValue; // underlying long of y

  
var xlow = xl & 0x00000000FFFFFFFF; // take the 32 lowest bits of x
  
var xhigh = xl >> 32; // take the 32 highest bits of x
  
var ylow = yl & 0x00000000FFFFFFFF; // take the 32 lowest bits of y
  
var yhigh = yl >> 32; // take the 32 highest bits of y

  
// perform multiplications
  
var lowlow = xlow * ylow;
  
var lowhigh = xlow * yhigh;
  
var highlow = xhigh * ylow;
  
var highhigh = xhigh * yhigh;

  
// take the highest bits of lowlow and the lowest of highhigh
  
var loResult = lowlow >> 32;
  
var midResult1 = lowhigh;
  
var midResult2 = highlow;
  
var hiResult = highhigh << 32;

  
// add everything together and build result
  
var finalResult = loResult + midResult1 + midResult2 + hiResult;
  

}


and the result be also in 64bit format. this works for same  format multiplication that is Q(4.60)*Q(4.60)=Q(4.60).

we need to consider sign bit also in the multiplication.

for different format Q(2.62)*Q(7.57)=Q(8.56) is not coming on the result.MaheshNjeyanthi.jegadeesan

 

Thanks advance,

 

Regards,

Balakumar.M

Outcomes