Next: , Previous: Financial Functions, Up: Financial Functions

8.6.1 Percentages

The M-% (calc-percent) command takes a percentage value, say 5.4, and converts it to an equivalent actual number. For example, 5.4 M-% enters 0.054 on the stack. (That's the <META> or <ESC> key combined with %.)

Actually, M-% creates a formula of the form ‘5.4%’. You can enter ‘5.4%’ yourself during algebraic entry. The ‘%’ operator simply means, “the preceding value divided by 100.” The ‘%’ operator has very high precedence, so that ‘1+8%’ is interpreted as ‘1+(8%)’, not as ‘(1+8)%’. (The ‘%’ operator is just a postfix notation for the percent function, just like ‘20!’ is the notation for ‘fact(20)’, or twenty-factorial.)

The formula ‘5.4%’ would normally evaluate immediately to 0.054, but the M-% command suppresses evaluation as it puts the formula onto the stack. However, the next Calc command that uses the formula ‘5.4%’ will evaluate it as its first step. The net effect is that you get to look at ‘5.4%’ on the stack, but Calc commands see it as ‘0.054’, which is what they expect.

In particular, ‘5.4%’ and ‘0.054’ are suitable values for the rate arguments of the various financial functions, but the number ‘5.4’ is probably not suitable—it represents a rate of 540 percent!

The key sequence M-% * effectively means “percent-of.” For example, 68 <RET> 25 M-% * computes 17, which is 25% of 68 (and also 68% of 25, which comes out to the same thing).

The c % (calc-convert-percent) command converts the value on the top of the stack from numeric to percentage form. For example, if 0.08 is on the stack, c % converts it to ‘8%’. The quantity is the same, it's just represented differently. (Contrast this with M-%, which would convert this number to ‘0.08%’.) The = key is a convenient way to convert a formula like ‘8%’ back to numeric form, 0.08.

To compute what percentage one quantity is of another quantity, use / c %. For example, 17 <RET> 68 / c % displays ‘25%’.

The b % (calc-percent-change) [relch] command calculates the percentage change from one number to another. For example, 40 <RET> 50 b % produces the answer ‘25%’, since 50 is 25% larger than 40. A negative result represents a decrease: 50 <RET> 40 b % produces ‘-20%’, since 40 is 20% smaller than 50. (The answers are different in magnitude because, in the first case, we're increasing by 25% of 40, but in the second case, we're decreasing by 20% of 50.) The effect of 40 <RET> 50 b % is to compute ‘(50-40)/40’, converting the answer to percentage form as if by c %.