# how to do fixed point multiply C code?

1. ## how to do fixed point multiply C code?

Is the following correct??

x.data=a.data *b.data;
x.wordlen=a.wordlen+b.wordlen;
x.fractlen=a.fractlen + b.fractlen;

??

Bcz My answer seems wrong...so help....~~

•

2. ## how to do fixed point multiply C code?

Please post a small, complete program, and tell us what answer you expected and what answer you got.

•

3. ## Re: how to do fixed point multiply C code?

type of x.data is correct
What I maen is "if type of a.data and b.data is same lets say unsigned int (32 bits)
then type of x.data must be long long unsigned int (64 bits)
Hope this help

•

4. ## Re: how to do fixed point multiply C code?

Originally Posted by nand_gates
What I maen is "if type of a.data and b.data is same lets say unsigned int (32 bits)
then type of x.data must be long long unsigned int (64 bits)
That wouldn't work. You have to cast at least one of the multiplicands to the larger integer type *before* multiplying them.

5. ## Re: how to do fixed point multiply C code?

mmm..
What I want is a general equation for all Q.format ....such as [16 18],[16 0],..[16 15],..........Is there any information about it?thanks for that.

--[[ ]]--