You are here

protected function Rectangle::fixImprecision in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::fixImprecision()
  2. 9 core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::fixImprecision()

Performs an imprecision check on the input value and fixes it if needed.

GD that uses C floats internally, whereas we at PHP level use C doubles. In some cases, we need to compensate imprecision.

Parameters

float $input: The input value.

float $imprecision: The imprecision factor.

Return value

float A value, where imprecision is added to input if the delta part of the input is lower than the absolute imprecision.

File

core/lib/Drupal/Component/Utility/Rectangle.php, line 141

Class

Rectangle
Rectangle rotation algebra class.

Namespace

Drupal\Component\Utility

Code

protected function fixImprecision($input, $imprecision) {
  if ($this
    ->delta($input) < abs($imprecision)) {
    return $input + $imprecision;
  }
  return $input;
}