[#mp_units-round-0e]
= xref:mp_units.adoc[mp&lowbar;units]::round
:relfileprefix: ../
:mrdocs:

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

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;math&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] auto To,
    auto R,
    typename Rep&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
constexpr
xref:mp_units/quantity-01.adoc[quantity&lt;detail&colon;&colon;clone&lowbar;reference&lowbar;with&lt;To&gt;(R), Rep&gt;]
round(xref:mp_units/quantity-01.adoc[quantity&lt;R, Rep&gt;] const& q) noexcept
requires requires &lcub;
    mp&lowbar;units&colon;&colon;floor&lt;To&gt;(q)&semi;
    representation&lowbar;values&lt;Rep&gt;&colon;&colon;one()&semi;
  &rcub; &amp;&amp; std&colon;&colon;constructible&lowbar;from&lt;std&colon;&colon;int64&lowbar;t, Rep&gt;;
----

== Description

Returns the value `res` representable in `To` unit that is the closest to `q`&period; If there are two such values, returns the even value (that is, the value `res` such that `res % 2 &equals;&equals; 0`)&period;

== Return Value

Quantity The quantity rounded to the nearest unit `To`, rounding to even in halfway cases&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *q*
| Quantity being the base of the operation
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
