From 26cf4c07099d3f09612d8fba16cb297bf6213bb8 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 15 Oct 2015 23:07:36 +0100 Subject: [PATCH] Remove savedPrecision from Calculation Engine --- src/PhpSpreadsheet/Calculation.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index b704f4c2..8b98d37f 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -201,12 +201,12 @@ class Calculation public $cyclicFormulaCount = 1; /** - * Precision used for calculations + * Epsilon Precision used for comparisons in calculations * * @var integer * */ - private $savedPrecision = 14; + private $delta = 0.0000000000001; /** @@ -2063,12 +2063,7 @@ class Calculation private function __construct(Spreadsheet $spreadsheet = null) { - $setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16; - $this->savedPrecision = ini_get('precision'); - if ($this->savedPrecision < $setPrecision) { - ini_set('precision', $setPrecision); - } - $this->delta = 1 * pow(10, -$setPrecision); + $this->delta = 1 * pow(10, 0 - ini_get('precision')); if ($spreadsheet !== null) { self::$spreadsheetSets[$spreadsheet->getID()] = $this; @@ -2080,13 +2075,6 @@ class Calculation } - public function __destruct() - { - if ($this->savedPrecision != ini_get('precision')) { - ini_set('precision', $this->savedPrecision); - } - } - private static function loadLocales() { $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';