Consider any floating-point value less than epsilon from zero as zero,
ie any value in the range [-epsilon < 0 < epsilon] is considered zero.
Also used to convert -0.0 to 0.0.

@param float $value
@param float $epsilon

@return float
516435
private static function checkZero(float $value, float $epsilon = self::EPSILON): float
    {
        return abs($value) < $epsilon ? 0.0 : $value;
    }
270702
public static function GAMMALN($value)
    {
        $value    = PHPExcel_Calculation_Functions::flattenSingleValue($value);

        if (is_numeric($value)) {
            if ($value <= 0) {
                return PHPExcel_Calculation_Functions::NaN();
            }
            return log(self::gamma($value));
        }
        return PHPExcel_Calculation_Functions::VALUE();
    }
1349576
public static function inferPrecision( $value, $decimals )
	{
		if ( $decimals == "INF" ) return INF;
		if ( ! is_numeric( $value ) ) return false;

		$fValue = floatval( $value );

		if ( $value === false ) return false;
		if ( $decimals === "" ) return 0;

		$precision = 0;
		if ( preg_match( '/[-+]?[0]*([1-9]?[0-9]*)([.])?(0*)([1-9]?[0-9]*)?([eE])?([-+]?[0-9]*)?/', $value, $matches ) )
		{
			list( $all, $nonZeroInt, $period, $zeroDec, $nonZeroDec, $e, $exp ) = $matches;
			$precision = (
				$nonZeroInt
					? strlen( $nonZeroInt )
					: ( $nonZeroDec ? -strlen( $zeroDec ) : 0 )
				) + ( $exp ? intval( $exp ) : 0 ) + ( intval( $decimals ) );

			if ( $precision < 0 ) $precision = 0;
		}

		return $precision;
	}
230647
public function setValue($value)
    {
        if ((\is_scalar($value) && \is_numeric($value))) {
            $this->value = (float) $value;
        } elseif (\is_object($value) && $value instanceof self) {
            $this->value = $value->getValue();
        }

        throw new \InvalidArgumentException('Expected double');
    }
939051
protected function min(float $value1 = null, float $value2 = null) {
        $temp1 = $value1 ?: 0;
        $temp2 = $value2 ?: 0;

        $tempmin = min($temp1, $temp2);

        if (!$tempmin && $value1 !== 0 && $value2 !== 0) {
            $min = null;
        } else {
            $min = $tempmin;
        }

        return $min;
    }
973498
public static BigRational valueOf(double value) {
		if (value == 0.0) {
			return ZERO;
		}
		if (value == 1.0) {
			return ONE;
		}
		if (Double.isInfinite(value)) {
			throw new NumberFormatException("Infinite");
		}
		if (Double.isNaN(value)) {
			throw new NumberFormatException("NaN");
		}
		return valueOf(new BigDecimal(String.valueOf(value)));
	}
670632
public function setAsFloat($value)
    {
        if (!(is_numeric($value) || $value instanceof NumericTypeInterface)) {
            throw new \InvalidArgumentException('value is not numeric');
        }
        $val = is_object($value) ? $value->asFloatType()->get() : floatval($value);
        $intVal = pow(10, $this->precision->get()) * $val;
        parent::set($intVal);

        return $this;
    }
1035596
private function getRatio(string $value) : float
    {
        if (strpos($value, '%') !== false) {
            $result = ((float)str_replace('%', '', $value)) / 100;
        } else {
            $result = $value;
        }

        return (float)$result;
    }
852738
public static function min($value, $min = 0, $equal = true)
    {
        return $equal ? $value >= $min : $value > $min;
    }
1124769
public static function float($value){

		$value = static::_nullValue($value);

		if($value !== null){

			// Avoid decimal separator nonsense
			$value = str_replace(',', '.', $value);
			$value = (float) $value;
		}

		return $value;
	}
1154132
protected function _validate_float($value)
    {
        if (is_int($value) || is_float($value)) {
            return $value;
        }

        if (filter_var($value, FILTER_VALIDATE_FLOAT) !== false
            && preg_match('#^[+-]?[\d\.]+$#', $value) === 1
        ) {
            return (float)$value;
        } else {
            return null;
        }
    }
610408
public static float toFloat(final Object value) {
		if (value instanceof Float) {
			return (float) value;
		}
		if (value == null) {
			return 0;
		}
		return new Float(value.toString());
	}
381300
protected function isSoftSmall($value)
    {
        if (!is_scalar($value) || $value === null) {
            return false;
        }
        
        $value = (float) $value;
        
        return $value >= 0 && $value <= 9;
    }
977029
public function number($value, $floatingPointNotation = false)
    {
        return number_format(
            $value,
            (true === $floatingPointNotation) ? $this->getConfiguration()->number->minor_unit : 0,
            $this->getConfiguration()->number->decimal_point,
            $this->getConfiguration()->number->thousands_separator
        );
    }
1288130
protected function isValueTooLow($value)
    {
        if ($this->min !== null) {
            if ((function_exists('bcsub') && floatval(bcsub($this->min, $value, 4)) > 0) || $value < $this->min) {
                return true;
            }
        }
        return false;
    }
799220
public function displayValue( $value )
    {
        return $this->view->numberFormat(
            (float) $value,
            NumberFormatter::DECIMAL,
            NumberFormatter::TYPE_DOUBLE
        );
    }
1228280
protected function isValid($value)
    {
        if (is_float($value)) {
            return;
        }
        if (!is_string($value) || strpos($value, '.') === false || preg_match('/^[0-9.e+-]+$/', $value) !== 1) {
            $this->addError('A valid float number is expected.', 1221560288);
        }
    }