# Re: Query on fmult in G.726

Started by April 30, 2002
 Hi all, I have a doubt in "FMULT" operation in G.726. The "fmult" is used to compute multiplication of fixed point number and a floating point number.In this function, the fixed point is first converted to floating point and the sign,magnitude and mantissas of both the floating point numbers are extracted. The resultant is computed as follows. WAnS = SRnS ** AnS ; signs of float1 float2 WAnEXP = SRnEXP + AnEXP ; exponents of float1 float2 WAnMANT = ((SRnMANT * AnMANT) + 48) >> 4 Mantissas of the two operands (Q6 format) are multiplied to form the product mantissa (Q12), which is then truncated in Q8 format.Thats why, we are right shifting the result by 4. But i dont understand why 48 is added to the product of mantissas. please clarify my doubt. Best regards, Prakash
 In order to round off properly, you need to add in the equivalent of 1/2 before you truncate, i.e. in plain C-syntax you would define int rnd(float x) { return int(x+0.5)} If you convert the exact value of zero to floating point, you would get "zero" == sign=0 exp=0 mant2 == 0x20 * 2^0 (follow the fmult code through to verify this statement). If you convert the value of one to floating point, you would get "one" == sign=0 exp=1 mant2 == 0x20 * 2^1 A representation of "half" in floating point can be derived by averaging "one" and "zero": half = (one + zero)>>1 = (0x20 *2^1 + 0x20 * 2^0)>>1 = (0x40 + 0x20) >> 1 = (0x60) >> 1 = 0x30 = 48 Note: This fmult definition is the same as in G.721, except it is coded as in hexadecimal 0x30 instead of 48. I am not sure that this is 100% correct, but it appears to be a plausible explanation. cheers, Mark Mark Lakata, Staff Engineer 1225 Charleston Road voice 650-567-5170 MIPS Technologies Mountain View CA 94043 fax 650-567-5002 On Tue, 30 Apr 2002, Bhanu Prakash wrote:> Hi all, > > I have a doubt in "FMULT" operation in G.726. > The "fmult" is used to compute multiplication of fixed point number and > a floating point number.In this function, the fixed point is first converted > to floating point and > the sign,magnitude and mantissas of both the floating point numbers are > extracted. > > The resultant is computed as follows. > > WAnS == SRnS ** AnS ; signs of float1 float2 > WAnEXP == SRnEXP + AnEXP ; exponents of float1 float2 > WAnMANT == ((SRnMANT * AnMANT) + 48) >> 4 > > Mantissas of the two operands (Q6 format) are multiplied to form the product > mantissa (Q12), > which is then truncated in Q8 format.Thats why, we are right shifting the > result by 4. > But i dont understand why 48 is added to the product of mantissas. > > please clarify my doubt. > Best regards, > Prakash > > _____________________________________ > Note: If you do a simple "reply" with your email client, only the author ofthis message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.> > _____________________________________ > About this discussion group: > > To Join: > > To Post: > > To Leave: > > Archives: http://www.yahoogroups.com/group/speechcoding > > Other DSP-Related Groups: http://www.dsprelated.com > ">http://docs.yahoo.com/info/terms/ >
Hi prakash ,
i believe the 48 is added for rounding the final prod. But like to have
more clarifications in depth.

vikram

-------Original Message-------

From: Bhanu Prakash
Date: Tuesday, April 30, 2002 21:18:30
To:
Subject: [speechcoding] Re: Query on fmult in G.726

Hi all,

I have a doubt in "FMULT" operation in G.726.
The "fmult" is used to compute multiplication of fixed point number and
a floating point number.In this function, the fixed point is first converted
to floating point and
the sign,magnitude and mantissas of both the floating point numbers are
extracted.

The resultant is computed as follows.

WAnS == SRnS ** AnS ; signs of float1 float2
WAnEXP == SRnEXP + AnEXP ; exponents of float1 float2
WAnMANT == ((SRnMANT * AnMANT) + 48) >> 4

Mantissas of the two operands (Q6 format) are multiplied to form the product
mantissa (Q12),
which is then truncated in Q8 format.Thats why, we are right shifting the
result by 4.
But i dont understand why 48 is added to the product of mantissas.

Best regards,
Prakash ------------------------ Yahoo! Groups Sponsor ---------------------~-->
and no minimums.
FREE Money 2002.
http://us.click.yahoo.com/k6cvND/n97DAA/ySSFAA/GP4qlB/TM
---------------------------------~->

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of

_____________________________________