The exp operator pops two numbers from the operand stack (base and exponent) and pushes base raised to the exponent power. If the exponent has a fractional part, the result is meaningful only if the base is non-negative. The result is always a real number.
This is a Level 1 operator, available in all PostScript implementations.
2. Syntax
baseexponentexpreal
2.1. Stack Effect
Table 1. Before Execution
Position
Content
Top
exponent (integer or real) - The power
Top-1
base (integer or real) - The base
Table 2. After Execution
Position
Content
Top
real (real) - base^exponent (always real)
3. Parameters
base
The base number (integer or real)
exponent
The power to raise to (integer or real)
4. Return Values
real
The result of base^exponent (always a real number)
% Negative base with integer exponent-23exp% → -8.0 (valid)-22exp% → 4.0 (valid)% WRONG: Negative base with fractional exponent-90.5exp% ERROR: undefinedresult