Method Deck / other
Percent of a value, or percent change between two values
Computes either a percentage of a base value, or the percent change from an old value to a new value.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
- operation (string, required) one of: percent_of, percent_change : Which calculation to perform.
- base (number, required) : For percent_of: the value to take a percentage of. For percent_change: the old (starting) value.
- percent (number, %, optional) : Required for percent_of: the percentage to apply to base.
- new_value (number, optional) : Required for percent_change: the new (ending) value.
Outputs
- result: For percent_of: the computed amount. For percent_change: the percent change (positive is an increase, negative a decrease).
Steps
- If operation is percent_of: result = base * percent / 100.
- If operation is percent_change: result = ((new_value - base) / base) * 100, expressed in percent.
- Round to 2 decimals.
Constants
None.
Sources
- Percentage and percent-change formulas (Standard arithmetic reference, 2026-09-30T19:56:00Z) - result=base*percent/100; percent change=(new-old)/old*100.
Worked example and test vectors
| Name | Inputs | Answer |
| worked example | {"operation":"percent_of","base":250,"percent":12} | 30.00 |
| test vector: percent change | {"operation":"percent_change","base":80,"new_value":100} | 25.00% |
Published card
- Address:
25a0677527959f9229c4a953b6dd860f
- Made at:
2026-09-30T22:39:30.722Z
- Method sha256:
cdd68c6bab5d357084db94aeca48dc604a92beaf13df6d84c5476a98dbb3ef38