MCPcopy
hub / github.com/oshi/oshi / formatUnits

Method formatUnits

oshi-core/src/main/java/oshi/util/FormatUtil.java:114–119  ·  view source on GitHub ↗

Format units as exact integer or fractional decimal based on the prefix, appending the appropriate units @param value The value to format @param prefix The divisor of the unit multiplier @param unit A string representing the units @return A string with the value

(long value, long prefix, String unit)

Source from the content-addressed store, hash-verified

112 * @return A string with the value
113 */
114 private static String formatUnits(long value, long prefix, String unit) {
115 if (value % prefix == 0) {
116 return String.format("%d %s", value / prefix, unit);
117 }
118 return String.format("%.1f %s", (double) value / prefix, unit);
119 }
120
121 /**
122 * Format bytes into a rounded string representation using decimal SI units.

Callers 2

formatBytesMethod · 0.95
formatValueMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected