Raxol.Utils.Format (Raxol v2.6.0)

View Source

Shared formatting utilities for human-readable output.

Summary

Functions

Formats a byte count as a human-readable string using SI units (1000-based).

Formats a byte count using binary units (1024-based, IEC).

Functions

format_bytes(bytes)

@spec format_bytes(number()) :: String.t()

Formats a byte count as a human-readable string using SI units (1000-based).

Examples

iex> Raxol.Utils.Format.format_bytes(1_500_000)
"1.5 MB"

iex> Raxol.Utils.Format.format_bytes(512)
"512 B"

format_bytes_iec(bytes)

@spec format_bytes_iec(number()) :: String.t()

Formats a byte count using binary units (1024-based, IEC).

Examples

iex> Raxol.Utils.Format.format_bytes_iec(1_048_576)
"1.0 MB"

iex> Raxol.Utils.Format.format_bytes_iec(512)
"512 B"