Thanks Laszlo for pointing that out. It appears that the rand() function is 
implemented on 32 bits in UEFI StdLib, instead of 16 bits as I was expecting. 
In this case the generated numbers are correct.


________________________________
 From: Laszlo Ersek <ler...@redhat.com>
To: Sorin Vinturis <sorin.vintu...@yahoo.com>; edk2-devel@lists.sourceforge.net 
Sent: Monday, 7 January 2013, 18:13
Subject: Re: [edk2] Generating random numbers in UEFI
 
On 01/07/13 16:30, Sorin Vinturis wrote:

> Does anyone knows why the generated numbers are over RAND_MAX, which is
> 32767?

From "StdLib/Include/stdlib.h":

   160  /** Expands to an integer constant expression that is the maximum value
   161      returned by the rand function.
   162  **/
   163  #define RAND_MAX  0x7fffffff

The value 32767 is an (inclusive) lower bound on RAND_MAX (ISO C99 7.20.2.1p5):

    The value of the RAND_MAX macro shall be at least 32767.

Laszlo
------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to