Click or drag to resize
AstroUtilsRange Method
Flexible routine to range a number into a given range between a lower and an higher bound.

Namespace: ASCOM.Astrometry.AstroUtils
Assembly: ASCOM.Astrometry (in ASCOM.Astrometry.dll) Version: 6.0.0.0 (6.3.0.2839)
Syntax
public double Range(
	double Value,
	double LowerBound,
	bool LowerEqual,
	double UpperBound,
	bool UpperEqual
)

Parameters

Value
Type: SystemDouble
Value to be ranged
LowerBound
Type: SystemDouble
Lowest value of the range
LowerEqual
Type: SystemBoolean
Boolean flag indicating whether the ranged value can have the lower bound value
UpperBound
Type: SystemDouble
Highest value of the range
UpperEqual
Type: SystemBoolean
Boolean flag indicating whether the ranged value can have the upper bound value

Return Value

Type: Double
The ranged nunmber as a double
Exceptions
ExceptionCondition
InvalidValueExceptionThrown if the lower bound is greater than the upper bound.
InvalidValueExceptionThrown if LowerEqual and UpperEqual are both false and the ranged value equals one of these values. This is impossible to handle as the algorithm will always violate one of the rules!
Remarks
UpperEqual and LowerEqual switches control whether the ranged value can be equal to either the upper and lower bounds. So, to range an hour angle into the range 0 to 23.999999.. hours, use this call:
RangedValue = Range(InputValue, 0.0, True, 24.0, False)

The input value will be returned in the range where 0.0 is an allowable value and 24.0 is not i.e. in the range 0..23.999999..

It is not permissible for both LowerEqual and UpperEqual to be false because it will not be possible to return a value that is exactly equal to either lower or upper bounds. An exception is thrown if this scenario is requested.

See Also