// MicroTip#1:随机生成某一范围的浮点数
// Wrtten by SkyJacker
function RandomFloat(L, H: Single): Single;
begin
repeat
Result := Random * H;
until (Result > L);
end;Author:
kendling Time: 2007-2-9 10:45
这样应该会单、快捷一点吧?
function RandomFloat(L, H: Single): Single;
begin
Result := Single((H - L + 1) * Random + L)
end;Author:
Passion Time: 2007-2-9 11:08
// 随机生成某一范围的浮点数
RandomFloat也需要做边界检查
function RandomFloat(L, H: Single): Single;
begin
if L > =H then
begin
Result := H;
exit;
end;
repeat
Result := Random * H;
until (Result > L);
end;