I've spent the last 5 hours trying to debug this darn thing . . . basically I want to store a float variable after doing some math, but it only stores as an int.
Programming in C with gcc, for Axon.
This below code either prints out +1.00000 if j=0 or +0.00000 for any other j value no greater than speed.
int j;
int speed;
float per_a;
per_a=(speed-j)/speed;
rprintfFloat(6, per_a);
And this below code only prints out +0.50000 no matter what, which makes sense.
int j;
int speed;
float per_a;
per_a=0.5;
rprintfFloat(6, per_a);
So the question is, what am I doing wrong in the first code example? I want it to give me a float value, not round it down as if it was an int variable . . .
Also, I tried this and various versions of it:
per_a=float((speed-j)/speed);
but always get this error:
error: expected expression before 'float'