From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12536 invoked by alias); 6 Aug 2011 16:34:30 -0000 Received: (qmail 12381 invoked by uid 22791); 6 Aug 2011 16:34:29 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail1-relais-roc.national.inria.fr (HELO mail1-relais-roc.national.inria.fr) (192.134.164.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 06 Aug 2011 16:34:15 +0000 Received: from afontenayssb-151-1-39-7.w83-114.abo.wanadoo.fr (HELO laptop-mg.local) ([83.114.89.7]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Aug 2011 18:34:13 +0200 Date: Sat, 06 Aug 2011 16:34:00 -0000 From: Marc Glisse Reply-To: gcc-help@gcc.gnu.org To: Andrew Haley cc: gcc-help@gcc.gnu.org, Anna Sidera Subject: Re: question on rand() In-Reply-To: <4E3D047D.4020603@redhat.com> Message-ID: References: <4E3D047D.4020603@redhat.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00069.txt.bz2 On Sat, 6 Aug 2011, Andrew Haley wrote: > On 08/06/2011 08:47 AM, Anna Sidera wrote: >> Hello, >> >> I am using gcc on a unix machine. Can you tell me how many random numbers can be generated using >> >> rand() >> >> before the random numbers start repeating? man rand If it's not there, complain to your unix vendor. The period is required by posix to be larger or equal to 2^32. > One would hope it has full period, i.e. it generates all RAND_MAX numbers, > but that depends on your system. One would even hope the period is larger, so the output of rand() is not a deterministic function of its last return value (random generators often keep a hidden state). -- Marc Glisse