This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

division remainder seems to be wrong

Hi all,

I need to recover the remainder of a division but no matter what I try the result comes out as 1.

so far I have tried:
u8 a = 10
u8 b = 3
u8 r;

r = a % b;
r = fmod(a,b)
res = div(a,b)
r = res.rem;

Casting applied in real code removed for ease of reading.
10/3 = 3.33 clearly
what I need is a way to recover the 33 etc, I expect it to be truncated but I didn't expect to get 1 or all remainders.

Compiler is realview Arm, on a STM32 cortex-m3.

Thanks,
Dave

Parents Reply Children
No data