** Next:** 3.2 SpreadScript Formulas
** Up:** 3. Calculations
** Previous:** 3. Calculations
** Contents**
** Index**

**Subsections**

#

3.1 How SpreadScript Calculates

Like Excel, SpreadScript uses natural order recalculation, which
is a method of ordering the computations such that each cell's
value is computed only after the values for all cells on which it
depends have been computed. Natural order recalculation guarantees
that cells are always computed correctly, regardless of the order
in which the cell formulas were entered.

###

3.1.0.1 Just-in-time recalculation

SpreadScript uses a technique called ``as needed'' or ``just-in-time''
recalculation, which defers the computation until the result
is actually needed. The performance gain in recalculation can be
significant, depending on the size and complexity of the
sheet.

SpreadScript provides two methods for Worksheet class related to
recalculation. The Worksheet::recalc() method will cause the worksheet's
formulas to be recalculated. It should be called before retrieving
the contents of a formula cell if any cells on the worksheet have been
altered since the last invocation of Worksheet::recalc().

The Worksheet::needsRecalc() method can be used to determine whether the
worksheet needs to be recalculated, due to alteration of the contents
of one or more cells. If the worksheet needs to be recalculated,
Worksheet::needsRecalc() will return 1 (True).

##

3.1.2 Precision

SpreadScript performs all calculations in double-precision.
Calculations with logical operators - `!`

(logical NOT),
`&&`

(logical AND), `||`

(logical OR),
and `?:`

(conditional)
- consider a non-zero value to be True and a zero value
to be False. Integer operators - `~`

(complement), `&`

(bitwise AND), `|`

(bitwise OR),
`^`

(bitwise EXCLUSIVE-OR),
and `%`

(modulus) convert their operands to 32-bit integers
before performing the operation.

** Next:** 3.2 SpreadScript Formulas
** Up:** 3. Calculations
** Previous:** 3. Calculations
** Contents**
** Index**
SpreadScript User's Guide, Version 1.2

Grey Trout Software

02 March 2003