Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final byte RANGE_EXCLUSIVE = 0; // 00
- public static final byte RANGE_INCLUSIVE = 3; // 11
- public static final byte RANGE_MAX_INCLUSIVE = 1; // 01
- public static final byte RANGE_MIN_INCLUSIVE = 2; // 10
- public static boolean inRange(long value, long range_a, long range_b, byte checkMode) {
- if (range_a > range_b) {
- long tmp = range_a;
- range_a = range_b;
- range_b = tmp;
- }
- // If value is on the left edge - check if it is inclusive
- if (value == range_a && (checkMode & RANGE_MIN_INCLUSIVE) == 0) return false;
- // If value is on the right edge - check if it is inclusive
- if (value == range_b && (checkMode & RANGE_MAX_INCLUSIVE) == 0) return false;
- // If value is out of range - return false
- if (value < range_a) return false;
- if (value > range_b) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement