Re: 63/64 bit version of Delphi's function random( aRange : integer ) : integer; ?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


sci.crypt archive

Re: 63/64 bit version of Delphi's function random( aRange : integer ) : integer; ?

From: Mike Warren <miwa-not-this-bit@or-this-csas.net.au>
Date: Fri Apr 28 2006 - 06:44:03 CEST

Skybuck Flying wrote:
>> I := Random($FFFFFFFF) * $100000000 + Random($FFFFFFFF);
>
> Where does the parameter go in ?

I thought you just wanted to generate a random Int64.

> It's missing ?
>
> Variable I is supposed to be in the range 0 to Parameter-1

Try this: (untested)

function Random64(Range: Int64): Int64;
var
  H, L: Int64;
begin
  H := Range and $FFFFFFFF00000000 div $100000000;
  L := Range and $FFFFFFFF;
  Result := Random(H) * $100000000 + Random(L);
end;

-Mike
Received on Mon May 1 02:05:26 2006