Sign in

username:

password:



Not a member?

Search compdsp



Search tips

comp.dsp by Keywords

Adaptive Filter | ADPCM | ADSP | ADSP-2181 | Aliasing | AMR | Anti-Aliasing | ARMA | Autocorrelation | AutoCovariance | Beamforming | Bessel | Blackfin | Butterworth | C6713 | CCS | Chebyshev | CIC Filter | Circular Convolution | Code Composer Studio | Comb Filter | Compression | Convolution | Cross Correlation | DCT | Decimation | Deconvolution | Demodulation | DM642 | DSP Boards | DSP/BIOS | DTMF | Echo Cancellation | Equalization | Equalizer | ETSI | EZLITE (Ez-kit Lite) | FFT | FFTW | FIR Filter | Fixed Point | FSK | G.711 | G.723 | G.729 | Gaussian Noise | Goertzel | GPIO | Hilbert Transform | IFFT | IIR Filter | Interpolation | Invariance | JTAG | Kalman | Laplace Transform | Levinson | LPC | McBSP | MIPS | Modulation | MPEG | Multirate | Notch Filter | Nyquist | OFDM | Oversampling | Pink Noise | Pitch | PLL | Polyphase | QAM | QDMA | Quantization | Quantizer | Radar | Random Noise | Reed Solomon | Remez | Resampling | RTDX | Sampling | Sharc | TI C6711 | Undersampling | Viterbi | Wavelets | White Noise | Wiener Filter | Windowing | XDS510PP | Z Transform


Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGAElectronics

Discussion Groups | Comp.DSP | floating point to fixed point conversion

There are 7 messages in this thread.

You are currently looking at messages 0 to 7.


floating point to fixed point conversion - riya - 2006-02-21 17:12:00

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.

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: floating point to fixed point conversion - Tim Wescott - 2006-02-21 17:44:00



riya 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.
> 
xFixed = xFloat * someGain;

If your compiler is strict try

xFixed = (int)(xFloat * someGain);

Surely this is what you already knew, not what you want?

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google?  See http://cfaj.freeshell.org/google/
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: floating point to fixed point conversion - Bhaskar Thiagarajan - 2006-02-21 20:14:00

"riya" <r...@gmail.com> wrote in message
news:1...@o13g2000cwo.googlegroups.com...
> 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.

Read this - it will give you an excellent start. If you have questions after
reading it, ask again
http://personal.bellsouth.net/~yatesc/fp.pdf

Decide on what precision you need for your fixed point data before trying to
write code.

Cheers
Bhaskar


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: floating point to fixed point conversion - Randy Yates - 2006-02-21 21:29:00

"Bhaskar Thiagarajan" <b...@deja.com> writes:

> "riya" <r...@gmail.com> wrote in message
> news:1...@o13g2000cwo.googlegroups.com...
>> 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.
>
> Read this - it will give you an excellent start. If you have questions after
> reading it, ask again
> http://personal.bellsouth.net/~yatesc/fp.pdf

Thanks Bhaskar. That's an old link. Try this:

  http://www.digitalsignallabs.com/fp.pdf
-- 
%  Randy Yates                  % "With time with what you've learned, 
%% Fuquay-Varina, NC            %  they'll kiss the ground you walk 
%%% 919-577-9882                %  upon."
%%%% <y...@ieee.org>           % '21st Century Man', *Time*, ELO
http://home.earthlink.net/~yatescr
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: floating point to fixed point conversion - Bhaskar Thiagarajan - 2006-02-22 12:29:00

"Randy Yates" <y...@ieee.org> wrote in message
news:m...@ieee.org...
> "Bhaskar Thiagarajan" <b...@deja.com> writes:
>
> > "riya" <r...@gmail.com> wrote in message
> > news:1...@o13g2000cwo.googlegroups.com...
> >> hello guys,

<snip>

> > Read this - it will give you an excellent start. If you have questions
after
> > reading it, ask again
> > http://personal.bellsouth.net/~yatesc/fp.pdf
>
> Thanks Bhaskar. That's an old link. Try this:
>
>   http://www.digitalsignallabs.com/fp.pdf
> -- 
> %  Randy Yates                  % "With time with what you've learned,

Well - the old one still seems to work. I'll update my bookmarks with the
new one.
I tried your new one and checked out the homepage of digitalsignallabs -
most links there don't work (perhaps you are already aware of this).

Cheers
Bhaskar


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: floating point to fixed point conversion - twain - 2006-02-23 10:22:00

Practically you need to define the following for each set of numbers 
that you want to represent in fixed-point:
1. their dynamic range,
2. the required resolution,

That would give you an idea of the number of bits needed (mantissa), and 
the representation format (exponent, block exponent or block float, Q15, 
Q14, Q28, Q31 etc.)

For practical approach you may check the introduction of ITU-T's G.728 
regarding fixed-point arithmetic.


riya 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.
> 
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: floating point to fixed point conversion - Leon - 2006-02-23 14:25:00

It can be very instructive to write a program in C to do the
conversions. It's useful for checking fixed-point and floating-point
code wriiten in assembler for a DSP, which is what I had to do, once.

Leon

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.