generate a huge amount of random numbers



How can I (or you) fasten up this procedure? The array has
40,000 elements.

//Fill an array of DWords where each bit is set randomly
//@param (BitsArray the array which have to be filled)
//@param (MaxProp defines the posibility for a bit to be set.
// for each Bit in the DWord := random < MaxProp
// range [0.0 .. 1.0] including)
procedure InitRandomBits(var BitsArray: array of DWord;
const MaxProp:Single);
var
i,j : Integer;
begin
for i := 0 to high(BitsArray) do
begin
BitsArray[i] := $00;

for j := 0 to 31 do
if random < MaxProp
then BitsArray[i] := BitsArray[i] or (1 shl j);
end;
end;


.



Relevant Pages

  • Re: Is it legal to type cast to DWORD* ???
    ... You are abusing an array by copying 4 byte quads into it. ... The only reason you might need an array of DWORDs shifted at integral ... indices would be some kind of binary compatibility. ... As a style rule that leads to technical rules, shun C style casts, such as ...
    (comp.lang.cpp)
  • Re: generate a huge amount of random numbers
    ... > The array has 40,000 elements. ... > //Fill an array of DWords where each bit is set randomly ... Regards, JohnH ... Prev by Date: ...
    (borland.public.delphi.language.basm)
  • CCcomBSTR to vector
    ... I receive values from an another application as a com string: ... And i need to store the values as DWORDs in an array, ...
    (microsoft.public.vc.language)
  • Re: Looking for speed performance to draw line.
    ... each item in an array, that being the next and/or previous indexes. ... and it's next pointer to the previous item's original next pointer. ... Next -1, Prev 0 ... shapes up into shape classes that implemented the required commands ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Multiple Condition Sumif Formula
    ... Andy. ... > revenue column. ... > & I've tried to enter the formula as an array by doing ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)