freq - Frequency Helpers
- Frequency Scaling Helpers – Methods like
hz(),khz(),mhz(),ghz(),thz(),phz(),ehz(),zhz(), andyhz()return Hertz-scaled unit calculations. - Type Preservation – Preserves input types (accepts and returns
intorfloatwithout casting) to avoid arithmetic precision loss.
Signature
sizelib.freq.<helper>(value: int | float) -> int | float| Helper Method | Multiplier Scale (Hertz) | Value (e.g. for input 1) |
|---|---|---|
| freq.hz(value) | 1 | 1 |
| freq.khz(value) | 1,000 | 1,000 |
| freq.mhz(value) | 1,000^2 | 1,000,000 |
| freq.ghz(value) | 1,000^3 | 1,000,000,000 |
| freq.thz(value) | 1,000^4 | 1,000,000,000,000 |
| freq.phz(value) | 1,000^5 | 1,000,000,000,000,000 |
| freq.ehz(value) | 1,000^6 | 1,000,000,000,000,000,000 |
| freq.zhz(value) | 1,000^7 | 1,000,000,000,000,000,000,000 |
| freq.yhz(value) | 1,000^8 | 1,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'>