function Rectangle::fixImprecision

Same name in other branches
  1. 9 core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::fixImprecision()
  2. 8.9.x core/lib/Drupal/Component/Utility/Rectangle.php \Drupal\Component\Utility\Rectangle::fixImprecision()
  3. 11.x 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.

1 call to Rectangle::fixImprecision()
Rectangle::rotate in core/lib/Drupal/Component/Utility/Rectangle.php
Rotates the rectangle.

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.