A formula is sequence of values, cell references, names, functions, or operators in a cell that together produce a new value. Formulas are stored in a tokenized representation known as "parsed expressions." In this section, formula is a synonym for parsed expression. A parsed expression is converted into a textual formula at runtime for display and user editing. Cell formulas are specified by the Formula record (section 2.4.127). Array formulas are specified by the Array record (section 2.4.4). Shared formulas are specified by the ShrFmla record (section 2.4.260).
Formulas that are part of a revision as specified in the Shared Workbooks overview (section 2.2.11) are specified by the pe.rgce field or the peOld.rgce field of the RRDDefName record (section 2.4.225), or by the xpe.rgce field or the xpeOld.rgce field of the RRDChgCell record (section 2.4.223).
A parsed expression contains a sequence of parse tokens, each of which is either an operand token (section 22.214.171.124), an operator token (section 126.96.36.199), a control token (section 188.8.131.52), a display token (section 184.108.40.206), or a mem token (section 220.127.116.11). All tokens are stored as Parse Things (Ptg (section 18.104.22.168)).
With the exception of control tokens (section 22.214.171.124), display tokens (section 126.96.36.199), and mem tokens (section 188.8.131.52) that are described in subsequent sections, parsed expressions are stored in Rgce (section 184.108.40.206) using Reverse-Polish notation. Reverse-Polish notation is a logical system for the specification of mathematical formulas in which operands are followed by operators. Inside an Rgce, the operands and operators are represented by an array of Ptg structures (section 220.127.116.11) of variable lengths. The first one or two bytes of a Ptg structure (section 18.104.22.168) contain the token type that determines which specific Ptg type (section 22.214.171.124) the Ptg is, as specified in the Ptg structure The remainder of the structure varies according to the token type.
Evaluation of a formula specified in Reverse-Polish notation is usually based around an evaluation stack. The expression is parsed from beginning to end, and operands are pushed onto the stack as they are encountered. When operators are encountered, the required number of operands is popped from the stack and the result of the operation is pushed back onto the stack. Evaluation begins with an empty stack, and when the evaluation is finished, there will be exactly one value left on the stack. The value is the result of the evaluation. Subsequent subsections refer to a stack as described by this model.