RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Math.EnsureRange Function

Returns the closest value to a specified value within a specified range.

Pascal
function EnsureRange(const AValue: Integer; const AMin: Integer; const AMax: Integer): Integer; overload;
function EnsureRange(const AValue: Int64; const AMin: Int64; const AMax: Int64): Int64; overload;
function EnsureRange(const AValue: Double; const AMin: Double; const AMax: Double): Double; overload;
C++
int EnsureRange(const int AValue, const int AMin, const int AMax);
Int64 EnsureRange(const Int64 AValue, const Int64 AMin, const Int64 AMax);
Double EnsureRange(const Double AValue, const Double AMin, const Double AMax);

Math

EnsureRange returns a value that is guaranteed to be within a specified range. 

AValue is the value you want as long as it is in range. If AValue is in range, EnsureRange returns AValue. 

AMin is the minimum acceptable value. If AValue is less than AMin, EnsureRange returns AMin. 

AMax is the maximum acceptable value. If AValue is greater than AMax, EnsureRange returns AMax. 

 

VarEnsureRange 

InRange

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!