Added a magnitiude addition helper function.

This commit is contained in:
2020-04-25 17:49:13 -05:00
parent 629660c8fc
commit 1e0d63e562
2 changed files with 16 additions and 0 deletions

View File

@@ -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;
}
}