human_freq() - Format Frequency

  • Frequency Formatting – Converts raw Hertz values into clean, readable frequency strings like 44.10 kHz, 800 MHz, 3.20 GHz, or 1.50 THz.
  • Smart Decimal Precision – Auto-rounds and formats fractional frequencies cleanly up to 2 decimal places.
  • Full SI Range – Automatically escalates frequency steps across Hz, kHz, MHz, GHz, THz, PHz, EHz, ZHz, and YHz.
Signature
sizelib.human_freq(hz: int | float) -> str

Output Unit Hierarchy Scale

UnitScale DivisorUnit Escalation Order
Frequency Units1000Hz → kHz → MHz → GHz → THz → PHz → EHz → ZHz → YHz
human_freq() - Usage
from sizelib import freq, human_freq

print(human_freq(44100))             # Output: 44.10 kHz
print(human_freq(freq.mhz(800)))     # Output: 800 MHz
print(human_freq(freq.ghz(3.2)))     # Output: 3.20 GHz
print(human_freq(freq.thz(1.5)))     # Output: 1.50 THz
human_freq() - Edge Cases & Exceptions
from sizelib import human_freq

# Zero Hz input
print(human_freq(0))                 # Output: 0 Hz

# Negative values raise ValueError
try:
    human_freq(-100)
except ValueError as e:
    print(e)                         # Output: Frequency cannot be negative