public function Measurement::round in Physical Fields 8
Rounds the current measurement.
Parameters
int $precision: The number of decimals to round to.
int $mode: The rounding mode. One of the following constants: PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_ODD.
Return value
static The rounded measurement.
File
- src/
Measurement.php, line 184
Class
- Measurement
- Provides a base class for measurement value objects.
Namespace
Drupal\physicalCode
public function round($precision = 0, $mode = PHP_ROUND_HALF_UP) {
$new_number = Calculator::round($this->number, $precision, $mode);
return new static($new_number, $this->unit);
}