+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Full Member level 3
    Points: 2,037, Level: 10

    Join Date
    Dec 2004
    Posts
    188
    Helped
    3 / 3
    Points
    2,037
    Level
    10

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

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 5
    Points: 32,456, Level: 44

    Join Date
    Apr 2002
    Location
    USA
    Posts
    3,942
    Helped
    663 / 663
    Points
    32,456
    Level
    44

    how to do fixed point multiply C code?

    Maybe yes, maybe no. Need more info.
    Please post a small, complete program, and tell us what answer you expected and what answer you got.



    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 3
    Points: 9,432, Level: 23

    Join Date
    Jul 2004
    Posts
    892
    Helped
    177 / 177
    Points
    9,432
    Level
    23

    Re: how to do fixed point multiply C code?

    Your code is correct if
    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



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 5
    Points: 32,456, Level: 44

    Join Date
    Apr 2002
    Location
    USA
    Posts
    3,942
    Helped
    663 / 663
    Points
    32,456
    Level
    44

    Re: how to do fixed point multiply C code?

    Quote 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. #5
    Full Member level 3
    Points: 2,037, Level: 10

    Join Date
    Dec 2004
    Posts
    188
    Helped
    3 / 3
    Points
    2,037
    Level
    10

    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.



--[[ ]]--