srecord Percent(double percent) { static Percent fromRatio(double ratio) { ret Percent(ratio*100); } static Percent fromRatio(double x, double y) { ret fromRatio(doubleRatio(x, y); } void set(double percent) { percent = percent; } double get() { ret percent; } toString { ret renderValue(percent) + " %"; } S renderValue(double percent) { ret formatDouble(percent, 1); } S renderWithDecimals aka withDecimals(int decimals) { ret formatDouble(percent, decimals) + " %"; } S withExactDecimals(int decimals) { ret formatDoubleX(percent, decimals) + " %"; } S oneDecimal() { ret withDecimals(1); } S exactlyOneDecimal() { ret withExactDecimals(1); } static Percent ratio(double x, double y) { ret new Percent(doubleRatio(x, y)*100); } }