Skip to content

mp_units::round

Computes the nearest quantity point with integer representation and unit type To to qp

Synopsis

Declared in <mp-units/math.h>

template<Unit auto To, auto R, auto PO, typename Rep>
[[nodiscard]] constexpr QuantityPointOf<quantity_point<R, PO, Rep>::quantity_spec> auto round(
  quantity_point<R, PO, Rep> const& qp) noexcept
  requires requires {
    mp_units::floor<To>(qp);
    representation_values<Rep>::one();
  } && std::constructible_from<std::int64_t, Rep>;

Description

Returns the value res representable in To unit that is the closest to qp. If there are two such values, returns the even value (that is, the value res such that res % 2 == 0).

Return Value

QuantityPoint The quantity rounded to the nearest unit To, rounding to even in halfway cases.

Note

The return value should not be discarded.

Parameters

NameDescription
qpQuantity point being the base of the operation