Rules | Recent posts | topic RSS | Search | Register  | Log in

Fixed point operations in C

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Author Message
kaushiksangam



Joined: 09 Apr 2006
Posts: 14


Post22 Aug 2006 14:27   Fixed point operations in C

I want to emulate an algorithm in C before actually writing to hardware.

This algorithm invovles lot of multiplications and additions of real numbers. Hence, I want to use fixed point operations(to represent real numbers) in C to emulate the algorithm.

Can someone please tell me or give me an example of how to perform fixed point operations in C.
Back to top
jagan326



Joined: 22 Aug 2006
Posts: 3


Post22 Aug 2006 16:18   Re: Fixed point operations in C

hey can u give me the details of this topic
Back to top
kaushiksangam



Joined: 09 Apr 2006
Posts: 14


Post22 Aug 2006 16:30   Re: Fixed point operations in C

It is about the implementation of a Brain State in a Box (BSB) algorithm. Before implementinng this in hardware, i would want to emulate the same in C.

Already have implemented algorithm in C through floating point oprations.

I can also send you the code of the implementation.
Back to top
neuralc



Joined: 06 Nov 2001
Posts: 270
Helped: 5


Post22 Aug 2006 19:11   Fixed point operations in C

Why dont use floating point?
Which up are you using?

NeuralC
Back to top
alvarorahul



Joined: 13 Apr 2005
Posts: 112
Helped: 5


Post23 Aug 2006 5:13   Fixed point operations in C

u can use an array of two integers for each number then, for example
0.004676 can be stored as
var1=4676 and var2= -3 u can u short int for the var2 coz im assuming that ur powers would not vary too much
Back to top
neuralc



Joined: 06 Nov 2001
Posts: 270
Helped: 5


Post24 Aug 2006 13:02   Fixed point operations in C

This is floating point....
Back to top
lambtron



Joined: 02 Nov 2005
Posts: 256
Helped: 26
Location: Portland, OR


Post24 Aug 2006 16:53   Re: Fixed point operations in C

kaushiksangam wrote:
Can someone please tell me or give me an example of how to perform fixed point operations in C.

Have a look at this: http://www.embedded.com/98/9804fe2.htm
Back to top
louisnells



Joined: 08 May 2006
Posts: 212
Helped: 13


Post25 Aug 2006 6:13   Re: Fixed point operations in C

Hi,
Fixed point operations in C is not that difficult to implement.
Lets say we are storing numbers in 8.24 format. So we can use a 32 bit un-signed integer for that. We are going to store the integer 8 bits in the MSB side and the fractional 24 bits on the LSB side (as we always represent in digital form - Little Endian). Then may be you should write a small library for fixed operations. Then implement operations like multiplication as bit-wise operations.
Back to top
rme_elektroda



Joined: 04 Oct 2006
Posts: 6


Post05 Oct 2006 10:27   Re: Fixed point operations in C

Probably useful link

http://www.embedded.com/showArticle.jhtml?articleID=15201575
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> PC Programming and Interfacing
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap