persistable sclass PercentIncrease { settable double percentIncrease; *(double *percentIncrease) {} double get() { ret percentIncrease; } double asFactor aka factor aka getFactor() { ret 1+percentIncrease/100; } static PercentIncrease of(double percentIncrease) { ret new PercentIncrease(percentIncrease); } static PercentIncrease fromFactor(double factor) { ret new PercentIncrease((factor-1)*100); } toString { ret plusMinusFix(formatDouble_significant(percentIncrease, 4)) + "%"; } PercentIncrease combineWith aka mul(PercentIncrease i) { ret fromFactor(asFactor()*i.asFactor()); } double applyTo aka mul(double x) { ret asFactor()*x; } // gets the n-th root (an increase you can apply n times to get the original one) PercentIncrease root aka nthRoot(double n) { ret fromFactor(Math.pow(asFactor(), 1/n)); } // gets the n-th power (an increase you can apply n times to get the original one) PercentIncrease pow aka repeat(double n) { ret fromFactor(Math.pow(asFactor(), n)); } }