floating point to fixed point conversion

Discussion in 'C Programming' started by riya1012@gmail.com, Feb 21, 2006.

  1. Guest

    hello guys,

    I need some help from you. I am doing a DSP project and for that I need
    to do some C coding for the conversion of sample data which is in
    floating point representation to fixed point representation.
    the sample data is in floating point like
    0.224128
    2.299965
    0.448350
    -1.779926
    My DSP algorithm is implemented in C and is supposed to be using fixed
    point representation.
    The above data is intended to be converted to fixed integer format.I
    request you to help me out regarding this conversion.I will be very
    glad if u give me some hints or algorithms for this conversion.
     
    , Feb 21, 2006
    #1
    1. Advertising

  2. Grumble Guest

    wrote:
    > I need some help from you. I am doing a DSP project and for that I need
    > to do some C coding for the conversion of sample data which is in
    > floating point representation to fixed point representation.
    > the sample data is in floating point like
    > 0.224128
    > 2.299965
    > 0.448350
    > -1.779926
    > My DSP algorithm is implemented in C and is supposed to be using fixed
    > point representation.
    > The above data is intended to be converted to fixed integer format.I
    > request you to help me out regarding this conversion.I will be very
    > glad if u give me some hints or algorithms for this conversion.


    Well, you've already asked in comp.dsp and comp.arch.embedded

    Newsgroups: comp.dsp
    Subject: floating point to fixed point conversion
    Date: 21 Feb 2006 14:12:58 -0800
    Message-ID: <>

    Newsgroups: comp.arch.embedded
    Subject: floating point to fixed point conversion
    Date: 21 Feb 2006 14:29:45 -0800
    Message-ID: <>

    You should learn to cross-post and set a followup-to.
     
    Grumble, Feb 22, 2006
    #2
    1. Advertising

  3. <> wrote in message
    news:...
    > hello guys,
    >
    > I need some help from you. I am doing a DSP project and for that I need
    > to do some C coding for the conversion of sample data which is in
    > floating point representation to fixed point representation.
    > the sample data is in floating point like
    > 0.224128
    > 2.299965
    > 0.448350
    > -1.779926
    > My DSP algorithm is implemented in C and is supposed to be using fixed
    > point representation.
    > The above data is intended to be converted to fixed integer format.I
    > request you to help me out regarding this conversion.I will be very
    > glad if u give me some hints or algorithms for this conversion.


    Most can probably help you with scaling the data, but few can help with the
    FFTs etc. You'll need to provide more information about your compiler and
    the data. What is the range of the floating point data? What are the sizes
    of long long, long, short, char, etc., of your compiler. If the range of
    the floating point data is highly limited, you could just multiply by 100,
    10000, etc. If the range is very wide, then you'll need large integers
    64-bits in size which might be 'long long' for your compiler. Perhaps
    provide a small piece of code showing what you are thinking or experimenting
    with.


    Rod Pemberton
     
    Rod Pemberton, Feb 22, 2006
    #3
  4. suresh Guest

    wrote:
    > hello guys,
    >
    > I need some help from you. I am doing a DSP project and for that I need
    > to do some C coding for the conversion of sample data which is in
    > floating point representation to fixed point representation.
    > the sample data is in floating point like
    > 0.224128
    > 2.299965
    > 0.448350
    > -1.779926
    > My DSP algorithm is implemented in C and is supposed to be using fixed
    > point representation.
    > The above data is intended to be converted to fixed integer format.I
    > request you to help me out regarding this conversion.I will be very
    > glad if u give me some hints or algorithms for this conversion.


    What is the precision of your fixed point number?

    Let us say it is 2 ^ (-N), then all that you need to do is

    long conv_to_fixed(float f)
    {
    return f * _2_power_N;
    }

    For example if you need 1/256 precision (x.8 format) then

    return f * 256.
     
    suresh, Feb 22, 2006
    #4
  5. Default User Guest

    Grumble wrote:

    > wrote:
    > > I need some help from you. I am doing a DSP project and for that I
    > > need to do some C coding for the conversion of sample data which is
    > > in floating point representation to fixed point representation.


    > Well, you've already asked in comp.dsp and comp.arch.embedded


    > You should learn to cross-post and set a followup-to.


    Yes and no. If a post really needs to be seen by more than one group
    (seldom is this really true) then cross-posting is correct. However,
    setting follow-ups is, in my opinion, rude. What, you expect people to
    go and subscribe to a new group to follow the thread? If the original
    question was topical for the newsgroup, then so are the replies.

    Follow-ups are only (again my opinion) proper for redirections.



    Brian
     
    Default User, Feb 22, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H aka N
    Replies:
    15
    Views:
    15,786
    Ben Jones
    Mar 2, 2006
  2. Motaz Saad
    Replies:
    7
    Views:
    6,528
  3. Roger Leigh
    Replies:
    4
    Views:
    484
    Roger Leigh
    Nov 12, 2003
  4. Satpreet
    Replies:
    1
    Views:
    487
    Michael Mair
    Feb 27, 2006
  5. Satpreet
    Replies:
    0
    Views:
    364
    Satpreet
    Feb 27, 2006
Loading...

Share This Page