From: riya1012 on
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.

From: Jeffrey R. Carter on
riya1012(a)gmail.com 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.

This is c.l.ada. We're for engineering SW in Ada, not for "C coding".

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

I have no idea how to convert floating-point values to fixed point in C, and
this does not seem to be the right place to be asking about that. As far as I
know, C does not have fixed-point types. Ada does; yet another reason to use
Ada. If you get a useful answer about C coding here, it will be pure luck. I
suggest you try c.l.c.

If I'm misinterpreting your question, and this does have something to do with
Ada, perhaps you can rephrase it in a manner that makes that clear.

--
Jeff Carter
"Death awaits you all, with nasty, big, pointy teeth!"
Monty Python & the Holy Grail
20
From: Keith Thompson on
riya1012(a)gmail.com writes:
> 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.

Um, why are you asking about C coding in comp.lang.ada?

--
Keith Thompson (The_Other_Keith) kst-u(a)mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
From: Keith Thompson on
Keith Thompson <kst-u(a)mib.org> writes:
> riya1012(a)gmail.com writes:
>> 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
[snip]
>
> Um, why are you asking about C coding in comp.lang.ada?

As well as comp.arch.embedded, comp.lang.c, comp.graphics.algorithms,
comp.arch.arithmetic, and comp.dsp.

--
Keith Thompson (The_Other_Keith) kst-u(a)mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
From: stuart clark on
Not sure if this is what you are after but an example from a real IDD,
where floats are represented as 16 bit signed integers, the 16th bit is
the sign bit.

Eg from a real life navigational computer IDD

magnetic heading = +/-180 degrees.
bits to use = 15, the 16th bit the sign bit

pass integers across an interface, which are then converted to floats
using a known scaling factor.

scaling factor = 180 / (2^15 ) = 0.005493....

we define the integer value of 1 = 0.005493.... and we call this value
the LSB.

>From basics where 15 bits can represent a max value of 2^15 -1 we now
have max value of 180 - LSB (iw 2^15 =180 and 1 =LSB)

therefore to send 180 - LSB across an interface what integer value do
you need = 180 / scaling factor = (180 - 0.005493..) / 0.005493 =
32767 (the old 2^15-1) = 0x7FFF

90 degrees = 90 / 0.005493 = 16383.5 = 0x3FFF

but note there is an accuracy loss as

0x3FFF * 0.005493 = 89.997

Thats hows its done in real life, hope it helps!

Stuart Clark