From 0eb11a6498ee3e6283cf17e826841839809f465d Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 26 Oct 2020 06:13:53 +0100 Subject: [PATCH] JPL.Math: +func. RandomBool --- Base/JPL.Math.pas | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Base/JPL.Math.pas b/Base/JPL.Math.pas index fe3307d..7213c33 100644 --- a/Base/JPL.Math.pas +++ b/Base/JPL.Math.pas @@ -41,6 +41,7 @@ function InRange(const Value, Min, Max: integer): Boolean; function RandomInt(const Min, Max: integer; ErrorValue: integer = -1): integer; function RandomByte(Min: Byte = 0; Max: Byte = 255; ErrorValue: Byte = 0): Byte; +function RandomBool: Boolean; implementation @@ -61,6 +62,11 @@ function RandomByte(Min: Byte = 0; Max: Byte = 255; ErrorValue: Byte = 0): Byte; Result := Random((Max - Min) + 1) + Min; end; +function RandomBool: Boolean; +begin + Result := RandomByte(0, 1) = 1; +end; + function InRange(const Value, Min, Max: integer): Boolean; begin