Skip to content

mp_units::round

round overloads

Synopses

Declared in <mp-units/math.h>

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

template<Unit auto To, auto R, typename Rep>
[[nodiscard]] constexpr quantity<detail::clone_reference_with<To>(R), Rep> round(quantity<R, Rep> const& q) noexcept
  requires requires {
    mp_units::floor<To>(q);
    representation_values<Rep>::one();
  } && std::constructible_from<std::int64_t, Rep>;

» more...

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

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

» more...

Return Value

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

Note

The return value should not be discarded.

Template Parameters

NameDescription
qQuantity being the base of the operation

Parameters

NameDescription
qpQuantity point being the base of the operation