Random number generator (included): Difference between revisions

(→‎{{header|Go}}: add issue link, add x/exp/rand)
Line 221:
function Random ( LimitPlusOne : Integer ) : Integer;
procedure Randomize;
 
Based on the values given in the wikipedia entry here is a Delphi compatible implementation for use in other pascal dialects.
<lang pascal>
{$ifdef fpc}{$mode objfpc}{$endif}
interface
function LCGRandom: extended; overload;inline;
function LCGRandom(const range:longint):longint;overload;inline;
implementation
function IM:cardinal;inline;
begin
RandSeed := RandSeed * 134775813 + 1;
Result := RandSeed;
end;
function LCGRandom: extended; overload;inline;
begin
Result := IM * 2.32830643653870e-10;
end;
function LCGRandom(const range:longint):longint;overload;inline;
begin
Result := IM * range shr 32;
end;
end.</lang>
 
=={{header|DWScript}}==
64

edits