Skip to content

Commit

Permalink
Fix rendering of negative numbers in columm layout
Browse files Browse the repository at this point in the history
Target: trunk
Require-notes: no
Require-book: no
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/7008/
(cherry picked from commit 85d9e29)
  • Loading branch information
gbehrmann committed May 15, 2014
1 parent 9c030cf commit 0d282de
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/dcache/src/main/java/org/dcache/util/ColumnWriter.java
Expand Up @@ -271,7 +271,7 @@ public int width(Object value)
private void render(long value, long factor, char unit, PrintWriter out)
{
double tmp = ((double) value) / factor;
if (tmp < 9.95) {
if (tmp >= 0 && tmp < 9.95) {
out.format("%3.1f", tmp).append(unit);
} else {
out.format("%3.0f", tmp).append(unit);
Expand All @@ -287,17 +287,18 @@ public void render(Object o, int actualWidth, PrintWriter out)
}
} else {
long value = (long) o;
long abs = Math.abs(value);
if (!abbrev) {
out.format("%" + actualWidth + "d", value);
} else if (value >= PETA) {
} else if (abs >= PETA) {
render(value, PETA, 'P', out);
} else if (value >= TERA) {
} else if (abs >= TERA) {
render(value, TERA, 'T', out);
} else if (value >= GIGA) {
} else if (abs >= GIGA) {
render(value, GIGA, 'G', out);
} else if (value >= MEGA) {
} else if (abs >= MEGA) {
render(value, MEGA, 'M', out);
} else if (value >= KILO) {
} else if (abs >= KILO) {
render(value, KILO, 'k', out);
} else {
out.format("%3d", value).append('B');
Expand Down

0 comments on commit 0d282de

Please sign in to comment.