# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Calculation/MathTrig/Helpers.php

TablePress – Tables in WordPress made easy, version 3.4. 121 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/MathTrig/Helpers.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Calculation/MathTrig/Helpers.php
- Modified: 2026-09-30T03:50:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/MathTrig/Helpers.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\MathTrig;

use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Functions;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;

class Helpers
{
	/**
	 * Many functions accept null/false/true argument treated as 0/0/1.
	 *
	 * @return float|string quotient or DIV0 if denominator is too small
	 */
	public static function verySmallDenominator(float $numerator, float $denominator)
	{
		return (abs($denominator) < 1.0E-12) ? ExcelError::DIV0() : ($numerator / $denominator);
	}

	/**
				 * Many functions accept null/false/true argument treated as 0/0/1.
				 * @return int|float
				 * @param mixed $number
				 */
				public static function validateNumericNullBool($number)
	{
		$number = Functions::flattenSingleValue($number);
		if ($number === null) {
			return 0;
		}
		if (is_bool($number)) {
			return (int) $number;
		}
		if (is_numeric($number)) {
			return 0 + $number;
		}

		throw new Exception(ExcelError::throwError($number));
	}

	/**
				 * Validate numeric, but allow substitute for null.
				 * @param null|float|int $substitute
				 * @return float|int
				 * @param mixed $number
				 */
				public static function validateNumericNullSubstitution($number, $substitute)
	{
		$number = Functions::flattenSingleValue($number);
		if ($number === null && $substitute !== null) {
			return $substitute;
		}
		if (is_numeric($number)) {
			return 0 + $number;
		}

		throw new Exception(ExcelError::throwError($number));
	}

	/**
				 * Confirm number >= 0.
				 * @param float|int $number
				 */
				public static function validateNotNegative($number, ?string $except = null): void
	{
		if ($number >= 0) {
			return;
		}

		throw new Exception($except ?? ExcelError::NAN());
	}

	/**
				 * Confirm number > 0.
				 * @param float|int $number
				 */
				public static function validatePositive($number, ?string $except = null): void
	{
		if ($number > 0) {
			return;
		}

		throw new Exception($except ?? ExcelError::NAN());
	}

	/**
				 * Confirm number != 0.
				 * @param float|int $number
				 */
				public static function validateNotZero($number): void
	{
		if ($number) {
			return;
		}

		throw new Exception(ExcelError::DIV0());
	}

	public static function returnSign(float $number): int
	{
		return $number ? (($number > 0) ? 1 : -1) : 0;
	}

	public static function getEven(float $number): float
	{
		$significance = 2 * self::returnSign($number);

		return $significance ? (ceil($number / $significance) * $significance) : 0;
	}

	/**
				 * Return NAN or value depending on argument.
				 * @return float|string
				 */
				public static function numberOrNan(float $result)
	{
		return is_nan($result) ? ExcelError::NAN() : $result;
	}
}

```
