Index: uspace/lib/c/generic/capa.c
===================================================================
--- uspace/lib/c/generic/capa.c	(revision c24b0dcbc89da1b8b0d83e5d3cd40cf5fcf3b37b)
+++ uspace/lib/c/generic/capa.c	(revision e28175d7eb3aea0200054019deabcae2e8f6cefd)
@@ -153,4 +153,5 @@
 	assert(rc == EOK);
 
+	/* Change units until we have no more than scapa_max_idig integer digits */
 	while (capa->m / div >= maxv) {
 		++capa->cunit;
@@ -170,6 +171,27 @@
 		assert(rc == EOK);
 
+		/* Division with rounding */
 		capa->m = (capa->m + (div / 2)) / div;
 		capa->dp -= rdig;
+	}
+
+	/*
+	 * If we rounded up from something like 999.95 to 1000.0,, we still
+	 * have more than scapa_max_idig integer digits and need to change
+	 * units once more.
+	 */
+	rc = ipow10_u64(capa->dp, &div);
+	assert(rc == EOK);
+
+	if (capa->m / div >= 1000) {
+		++capa->cunit;
+		capa->dp += 3;
+
+		/*
+		 * We now have one more significant digit than we want
+		 * so round to one less digits
+		 */
+		capa->m = (capa->m + 5) / 10;
+		--capa->dp;
 	}
 }
@@ -202,4 +224,5 @@
 		ret = asprintf(rstr, "%" PRIu64 " %s", ipart, sunit);
 	}
+
 	if (ret < 0)
 		return ENOMEM;
