Hi
I suspect that rand() is not working in eCos libc if using Knuth algorithm:
File: rand.cxx, line 197
*seed = AA*(*seed % QQ) - RR*(unsigned int)(*seed/QQ);
if (*seed < 0)
*seed += MM;
Since "seed" variable is unsigned pointer, the comparison with 0 will always
result FALSE.
I dont know if this is the idea, but maybe something like this could help to
use a temporary signed varialbe
- *seed = AA*(*seed % QQ) - RR*(unsigned int)(*seed/QQ);
- if (*seed < 0)
- *seed += MM;
+ signed int s = AA*(*seed % QQ) - RR*(unsigned int)(*seed/QQ);
+ *seed = (unsigned int)s;
+ if (s < 0)
+ *seed += MM;
Best Regards
/Fredrik