Added a magnitiude addition helper function.
This commit is contained in:
@@ -18,4 +18,11 @@ public class Utilities {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static int addMagnitude(int value, int add) {
|
||||
boolean negative = false;
|
||||
if (value < 0) negative = true;
|
||||
int res = Math.abs(value) + add;
|
||||
return negative ? - res : res;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user