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.
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).
SpreadScript performs all calculations in double-precision.
Calculations with logical operators -
! (logical NOT),
&& (logical AND),
|| (logical OR),
- consider a non-zero value to be True and a zero value
to be False. Integer operators -
| (bitwise OR),
^ (bitwise EXCLUSIVE-OR),
% (modulus) convert their operands to 32-bit integers
before performing the operation.