forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathisBetween.as
More file actions
21 lines (20 loc) · 772 Bytes
/
isBetween.as
File metadata and controls
21 lines (20 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package utils.number
{
/**
Determines if the value is included within a range.
@param value: Number to determine if it is included in the range.
@param firstValue: First value of the range.
@param secondValue: Second value of the range.
@return Returns <code>true</code> if the number falls within the range; otherwise <code>false</code>.
@usageNote The range values do not need to be in order.
@example
<code>
trace(NumberUtil.isBetween(3, 0, 5)); // Traces true
trace(NumberUtil.isBetween(7, 0, 5)); // Traces false
</code>
*/
public function isBetween(value:Number, firstValue:Number, secondValue:Number):Boolean
{
return !(value < Math.min(firstValue, secondValue) || value > Math.max(firstValue, secondValue));
}
}