freq - Frequency Helpers

  • Frequency Scaling Helpers – Methods like hz(), khz(), mhz(), ghz(), thz(), phz(), ehz(), zhz(), and yhz() return Hertz-scaled unit calculations.
  • Type Preservation – Preserves input types (accepts and returns int or float without casting) to avoid arithmetic precision loss.
Signature
sizelib.freq.<helper>(value: int | float) -> int | float
Helper MethodMultiplier Scale (Hertz)Value (e.g. for input 1)
freq.hz(value)11
freq.khz(value)1,0001,000
freq.mhz(value)1,000^21,000,000
freq.ghz(value)1,000^31,000,000,000
freq.thz(value)1,000^41,000,000,000,000
freq.phz(value)1,000^51,000,000,000,000,000
freq.ehz(value)1,000^61,000,000,000,000,000,000
freq.zhz(value)1,000^71,000,000,000,000,000,000,000
freq.yhz(value)1,000^81,000,000,000,000,000,000,000,000
freq API - Basic Usage
from sizelib import freq

# Define frequency constraints cleanly in Hz
CPU_BASE_CLOCK = freq.ghz(3.2)      # 3.2 GHz (3200000000.0 Hz)
RAM_SPEED = freq.mhz(3200)          # 3200 MHz (3200000000 Hz)
AUDIO_SAMPLE_RATE = freq.khz(44.1)  # 44.1 kHz (44100.0 Hz)
RADIO_BAND = freq.mhz(100)          # 100 MHz (100000000 Hz)
freq API - Variables & Expressions
from sizelib import freq

# Variables and expressions are fully supported
multiplier = 4.5
clock_speed = freq.ghz(multiplier)  # 4.5 GHz (4500000000.0 Hz)
freq API - Type Preservation
from sizelib import freq

# Input types (int/float) are dynamically preserved
BASE_CLOCK = freq.mhz(800)
print(BASE_CLOCK)                   # Output: 800000000
print(type(BASE_CLOCK))             # Output: <class 'int'>

BOOST_CLOCK = freq.ghz(4.8)
print(BOOST_CLOCK)                  # Output: 4800000000.0
print(type(BOOST_CLOCK))            # Output: <class 'float'>