/** * Setups the math * * @param integer $defaultPrecision The default precision * @return void */ public static function setup($defaultPrecision = null) { if (self::$setup) { return; } if ($defaultPrecision) { self::$defaultPrecision = (int) $defaultPrecision; } bcscale(self::$defaultPrecision); self::$oldPrecision = array(ini_get('precision'), ini_get('bcmath.scale')); if (function_exists('ini_set')) { ini_set('bcmath.scale', self::$defaultPrecision); ini_set('precision', self::$defaultPrecision); } else { trigger_error('Math precision could not be set due to forbidden "ini_set" function.', E_USER_WARNING); } self::$setup = true; }