Does anyone know of a division function in C for fixed-point numbers?
I am using ac_fixed header but apparently that doesn't work since I'm getting zeros when I do 1/a where "a" is a fixed-type with values between 30-60.
If a is of type INT (int8, int16 or int32) in the 30-60 range, the result of 1/a will always give zero (e.g. 1/35 = 0,0285714, but INT(0,0285714)=0 ) because of implicit conversion (operation with two INT will give the result of type INT).
If you need to store the result into the variable named Result of type FLOAT, you need to perform explicit conversion:
int a;
float Result;
...
a = 35;
...
Result = (float)(1/a)
...