aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-20 13:59:44 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-20 13:59:44 +1300
commit06b5113f3d98a44530c2ade6810bc75092fccc31 (patch)
treecb8c03c8f3394db0691b73547e86d2a181462607 /src/org/traccar/helper
parent7b103b43754de283e423df03042c6f75307c8466 (diff)
downloadtrackermap-server-06b5113f3d98a44530c2ade6810bc75092fccc31.tar.gz
trackermap-server-06b5113f3d98a44530c2ade6810bc75092fccc31.tar.bz2
trackermap-server-06b5113f3d98a44530c2ade6810bc75092fccc31.zip
Refactor bit utililies class
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);
}
}