summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/math
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-09-16 21:12:35 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-09-16 21:12:35 -0300
commit2f96f49c2d2c8679841c790e9dd7d9f1b6f3fed1 (patch)
tree23cfb315743bbb5c1c8fa749e75aba8a54e3a2f7 /base/src/main/java/bjc/utils/math
parent92c56c5918a0858aad32cc9ee0fb3eee99ebd007 (diff)
Large update
A large update, this contains much debugging of the CL FORMAT routines, as well as a few other minor changes.
Diffstat (limited to 'base/src/main/java/bjc/utils/math')
-rw-r--r--base/src/main/java/bjc/utils/math/NumberUtils.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/base/src/main/java/bjc/utils/math/NumberUtils.java b/base/src/main/java/bjc/utils/math/NumberUtils.java
index 53ab211..5c8ec7e 100644
--- a/base/src/main/java/bjc/utils/math/NumberUtils.java
+++ b/base/src/main/java/bjc/utils/math/NumberUtils.java
@@ -400,7 +400,7 @@ public class NumberUtils {
boolean isNeg = false;
long currVal = val;
if(currVal < 0) {
- isNeg = true;
+ isNeg = true;
currVal *= -1;
}
@@ -416,12 +416,11 @@ public class NumberUtils {
work.append(radixChars[radDigit]);
currVal = currVal / radix;
- if(commaInterval != 0 && valCounter % commaInterval == 0) work.append(commaChar);
+ if(commaInterval != 0 && valCounter % commaInterval == 0 && currVal != 0) work.append(commaChar);
}
}
- if(isNeg)
- work.append("-");
+ if(isNeg) work.append("-");
else if(signed) work.append("+");
work.reverse();
@@ -437,8 +436,21 @@ public class NumberUtils {
StringBuilder pad = new StringBuilder();
if(work.length() < mincols) {
+ int padCount = 0;
for(int i = work.length(); i < mincols; i++) {
- pad.append(padchar);
+ // @NOTE 9/6/18 :CommaPad
+ //
+ // I have no idea if this is the intended
+ // behavior, or if something is wrong with the
+ // example case in the menu
+ // if (commaInterval != 0 && padCount != 0) {
+ // if (Character.isDigit(padchar) && padCount % commaInterval == 0)
+ // pad.append(commaChar);
+ // else
+ pad.append(padchar);
+ // }
+
+ padCount++;
}
}