This is making me insane. I am trying to divide a long by a constant and I can't get the compiler to do it.
unsigned int do_math(ulong long_speed)
{
ulong pulsetime = (long_speed/1000L);
pulsetime = (1000L/pulsetime);
pulsetime /= DEF_INT_RATE; // interupt rate
return (uint)pulsetime;
}
If the value of long_speed = 5000L, the first equation results in pulsetime = 968. Since when does 5000/1000 = 968???. What can I do to get the math to work? I already tried doubling the stack.
I tried making the 1000 1000.0. I tried way too many things just to get a very simple division to work.
Does anyone have a clue? Is there a codewarrior compiler guru out there?