Skip to content

Format a byte count as a human-readable size string

Formats a size the way the dvs CLI prints it. The size columns of dvs_add(), dvs_status() and dvs_get() print this way in a tibble.

format_byte_size(size_bytes)
ArgumentDescription
size_bytesA size in bytes: one whole number, 0 or more. TRUE and FALSE are refused.

A string. Below 1024 bytes it is the count with B, as in "512 B". From 1024 bytes up it has one decimal and the largest unit that fits: KB, MB, GB or TB. The units are powers of 1024, so format_byte_size(1e6) is "976.6 KB".