avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] bug in rand()/random()/do_rand()/do_random( )


From: Mikal Hart
Subject: [avr-libc-dev] bug in rand()/random()/do_rand()/do_random( )
Date: Sat, 3 Jan 2009 15:29:56 -0600

Hi all--

 

I hope I'm posting to the correct spot here.

 

We over in the Arduino development community (http://www.arduino.cc
<http://www.arduino.cc/> ) have observed what seems to be a bug in
avr-libc's random() and rand() (but only in Linux builds).

 

For example, if you run a little Arduino sketch (btw, Arduino uses the
AVR-168P) that calls random() nine times (without seeding), you immedately
get a repeat in your series:

 

0 31031784 26852320 4242000 842292 453960 211932 84160 0 ... and so on (!)

 

As you can see, these are not very random. :)  This example was generated
from an Ubuntu host.  Developers who use Windows don't seem to be affected.
The random() and rand() sequences with Windows are entirely reasonable.  

 

For more details, please see this thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227218077/45.

 

Thanks!  Is there somewhere else that I should post bug reports like this?

 

Mikal Hart

Intel Corporation

 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]