You are here

public function AbstractUnitsMathematicalOperator::evaluate in Units of Measurement 7.2

Numerically evaluate this mathematical expression.

Return value

float Numerical value of this mathematical expression

Throws

UnitsMathematicalExpressionDimensionException Exception is thrown if this mathematical expression has inconsistency in physical dimensions

Overrides UnitsMathematicalExpression::evaluate

1 method overrides AbstractUnitsMathematicalOperator::evaluate()
UnitsMathematicalOperatorNonLinear::evaluate in ./units.module
Numerically evaluate this mathematical expression.

File

./units.module, line 1403
Provide API for managing and converting units of measurement.

Class

AbstractUnitsMathematicalOperator
Abstract implementation of "mathematical operator" interface.

Code

public function evaluate() {
  if ($this->operator['dimension check'] && !units_dimension_equal($this->operand1
    ->dimension(), $this->operand2
    ->dimension())) {
    throw new UnitsMathematicalExpressionDimensionException();
  }
  list($evaluate1, $evaluate2) = $this
    ->evaluateOperands();
  $evaluate_callback = ctools_plugin_get_function($this->operator, 'evaluate callback');
  return $evaluate_callback($evaluate1, $evaluate2);
}