P
Peter Williams
Hi All,
I need to port the following (small) C language function to Delphi:
double Rand(void) {
return rand()/(1.0 + (double)RAND_MAX);
}
NB -- elsewhere in the program randomize is called before-hand.
I don't know what (exactly) the C language function "rand()" does.
Also, RAND_MAX is not defined anywhere in the program, so is it part of
C ???
My attempt at starting to write it in Delphi:
function Rand : Real;
begin
Result := ????????????????
end;
NB -- Delphi has a Random(N) function which takes an integer (N) as
it's parameter and returns an integer in the range 0..N-1 . E.g.
Random(3) would return either 0, 1, or 2.
NB(2) -- Obviously, Delphi also has a "randomize" function which I am
aware I need to call first.
Can anyone please assist me in writing this routine as a Delphi code
snippet???
Any help will be greatly appreciated.
Regards,
Peter W. ))
Sandy Bay, Hobart, Tas, AU.
I need to port the following (small) C language function to Delphi:
double Rand(void) {
return rand()/(1.0 + (double)RAND_MAX);
}
NB -- elsewhere in the program randomize is called before-hand.
I don't know what (exactly) the C language function "rand()" does.
Also, RAND_MAX is not defined anywhere in the program, so is it part of
C ???
My attempt at starting to write it in Delphi:
function Rand : Real;
begin
Result := ????????????????
end;
NB -- Delphi has a Random(N) function which takes an integer (N) as
it's parameter and returns an integer in the range 0..N-1 . E.g.
Random(3) would return either 0, 1, or 2.
NB(2) -- Obviously, Delphi also has a "randomize" function which I am
aware I need to call first.
Can anyone please assist me in writing this routine as a Delphi code
snippet???
Any help will be greatly appreciated.
Regards,
Peter W. ))
Sandy Bay, Hobart, Tas, AU.