srecord Frequency(double frequency) is Comparable { gettable double interval; double frequency aka get() { ret frequency; } // !customConstructor *(double *frequency) { interval = doubleRatio(1, frequency); } toString { ret format3(); } S format3() { ret format(3); } S format1() { ret format(1); } S format(int digits) { ret str(new Rendering(digits)); } record noeq Rendering(int digits) { double value = frequency; S unit = "Hz"; swappable S formatValue() { ret formatDouble(value, digits); } run { while (abs(value) >= 1000) { value /= 1000; unit = "k" + unit; } unit = replacePrefixes(unit, "kkkk", "T", "kkk", "G", "kk", "M"); } toString { run(); ret spaceCombine(formatValue(), unit); } } public int compareTo(Frequency f) { ret cmp(frequency, f.frequency); } }