aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/BitUtil.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/org/traccar/helper/BitUtil.java b/src/org/traccar/helper/BitUtil.java
index 81c638a68..31271a691 100644
--- a/src/org/traccar/helper/BitUtil.java
+++ b/src/org/traccar/helper/BitUtil.java
@@ -24,20 +24,28 @@ public final class BitUtil {
return (number & (1 << index)) != 0;
}
- public static int range(int number, int index) {
- return number >> index;
+ public static int between(int number, int from, int to) {
+ return (number >> from) & ((1 << to - from) - 1);
}
- public static int range(int number, int index, int length) {
- return (number >> index) & ((1 << length) - 1);
+ public static int from(int number, int from) {
+ return number >> from;
}
- public static long range(long number, int index) {
- return number >> index;
+ public static int to(int number, int to) {
+ return between(number, 0, to);
}
- public static long range(long number, int index, int length) {
- return (number >> index) & ((1L << length) - 1);
+ public static long between(long number, int from, int to) {
+ return (number >> from) & ((1L << to - from) - 1L);
+ }
+
+ public static long from(long number, int from) {
+ return number >> from;
+ }
+
+ public static long to(long number, int to) {
+ return between(number, 0, to);
}
}