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