Computes the nearest quantity with integer representation and unit type To
to q
Synopsis
Declared in <mp‐units/math.h>
template<
Unit auto To,
auto R,
typename Rep>
[[nodiscard]]
constexpr
quantity<detail::clone_reference_with<To>®, 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>;
Description
Returns the value res
representable in To
unit that is the closest to q
. If there are two such values, returns the even value (that is, the value res
such that res % 2 == 0
).
Return Value
Quantity The quantity rounded to the nearest unit To
, rounding to even in halfway cases.
Template Parameters
Name |
Description |
q |
Quantity being the base of the operation |
Parameters
Name |
Description |
q |
A quantity |
Created with MrDocs