package org.tizen.dynamicanalyzer.util;
-
public class UnsignedInt {
- private static final long MAX_VALUE = (long)Integer.MAX_VALUE * 2 + 1;
+ private static final long MAX_VALUE = (long) Integer.MAX_VALUE * 2 + 1;
private static final long MIN_VALUE = 0;
-
- private long value; // real data, use only 4byte.
-
+
+ private long value; // real data, use only 4byte.
+
public UnsignedInt() {
this.value = 0;
}
-
+
public UnsignedInt(int value) {
this.value = value & 0xFFFFFFFFL;
}
-
+
public UnsignedInt(long value) {
if (value > MAX_VALUE || value < MIN_VALUE) {
Logger.error("Invalid input : " + value + ". 0 will be set.");
this.value = value;
}
}
-
+
+ public boolean equals(Object o) {
+ if (o instanceof Long) {
+ Long l = (Long) o;
+ if (l.longValue() == value) {
+ return true;
+ } else {
+ return false;
+ }
+ } else if (o instanceof Integer) {
+ Integer i = (Integer) o;
+ if (i.longValue() == value) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
public long getValue() {
return value;
}
-
+
public void add(UnsignedInt operand) {
add(operand.getValue());
}
-
+
public void minus(UnsignedInt operand) {
minus(operand.getValue());
}
-
+
public void multiply(UnsignedInt operand) {
multiply(operand.getValue());
}
-
+
public void divide(UnsignedInt operand) {
divide(operand.getValue());
}
-
+
private void add(long operand) {
long temp = this.value + operand;
if (temp > MAX_VALUE) {
}
this.value = temp;
}
-
+
private void minus(long operand) {
long temp = this.value - operand;
if (temp < MIN_VALUE) {
}
this.value = temp;
}
-
+
private void multiply(long operand) {
long temp = this.value * operand;
if (temp > MAX_VALUE) {
}
this.value = temp;
}
-
+
private void divide(long operand) {
this.value /= operand;
}