This patch fixes the display of units on boundaries,for example
"1024" will be displayed as "1 KB" instead of "1024 B".
Change-Id: I3464d1d54e05254f3133d76faf2b75890690b766
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://git.eclipse.org/r/70698
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
{ 0, "0" },
{ 3, "3 B" },
{ 975, "975 B" },
{ 0, "0" },
{ 3, "3 B" },
{ 975, "975 B" },
+ { 1024, "1 KB" },
+ { 1024 * 1024, "1 MB" },
+ { 1024 * 1024 * 1024, "1 GB" },
+ { 1024L * 1024L * 1024L * 1024L, "1 TB" },
{ 4096, "4 KB" },
{ -4096, "-4 KB" },
{ 4096L, "4 KB" },
{ 4096, "4 KB" },
{ -4096, "-4 KB" },
{ 4096L, "4 KB" },
if (value == 0) {
return toAppendTo.append("0"); //$NON-NLS-1$
}
if (value == 0) {
return toAppendTo.append("0"); //$NON-NLS-1$
}
- if (abs > KILO * KILO * KILO * KILO) {
+ if (abs >= KILO * KILO * KILO * KILO) {
return toAppendTo.append(FORMAT.format(value / (KILO * KILO * KILO * KILO))).append(' ').append(TB);
}
return toAppendTo.append(FORMAT.format(value / (KILO * KILO * KILO * KILO))).append(' ').append(TB);
}
- if (abs > KILO * KILO * KILO) {
+ if (abs >= KILO * KILO * KILO) {
return toAppendTo.append(FORMAT.format(value / (KILO * KILO * KILO))).append(' ').append(GB);
}
return toAppendTo.append(FORMAT.format(value / (KILO * KILO * KILO))).append(' ').append(GB);
}
- if (abs > KILO * KILO) {
+ if (abs >= KILO * KILO) {
return toAppendTo.append(FORMAT.format(value / (KILO * KILO))).append(' ').append(MB);
}
return toAppendTo.append(FORMAT.format(value / (KILO * KILO))).append(' ').append(MB);
}
return toAppendTo.append(FORMAT.format(value / (KILO))).append(' ').append(KB);
}
return toAppendTo.append(FORMAT.format(value)).append(' ').append(B);
return toAppendTo.append(FORMAT.format(value / (KILO))).append(' ').append(KB);
}
return toAppendTo.append(FORMAT.format(value)).append(' ').append(B);