Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: RandomRange() with support for negative AFrom / ATo.
- [==============================================================================}
- function RandomRange2(AFrom, ATo: Integer): Integer;
- begin
- if (AFrom > ATo) then
- Swap(AFrom, ATo);
- if (AFrom < 0) then
- Result := (Random(IAbs(ATo - AFrom)) + AFrom)
- else
- Result := (Random(ATo - AFrom) + AFrom);
- end;
Advertisement
Add Comment
Please, Sign In to add comment