[#BloombergLP-bdlcc-FixedQueueIndexManager-circularDifference]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlcc.adoc[bdlcc]::xref:BloombergLP/bdlcc/FixedQueueIndexManager.adoc[FixedQueueIndexManager]::circularDifference
:relfileprefix: ../../../
:mrdocs:

Return the signed circular difference of two values modulo a bound&period;

== Synopsis

Declared in `&lt;bdlcc&lowbar;fixedqueueindexmanager&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
circularDifference(
    unsigned int minuend,
    unsigned int subtrahend,
    unsigned int modulo);
----

== Description

Return the difference between the specified `minuend` and the specified `subtrahend` (typically `minuend &hyphen; subtrahend`) where minuend and subtrahend are both &quot;circular values&quot;, meaning they are part of a non&hyphen;euclidean number line where the value wrap around to 0 at the specified `modulo`&period; The difference between two circular values is the minimum of either the number of increments or the number of decrements to `subtrahend` that results in `minuend` (i&period;e&period;, the minimum &quot;distance&quot; between the points on the number circle), where increments are a positive difference, and decrements are a negative difference&period; If the number of increments and number of decrements between `minuend` and `subtrahend` are equal, `minuend &hyphen; subtrahend` is returned&period; For example, for a hypothetical compass, &lsqb;0, 360)&colon;&rsqb; &grave; circularDifference( 0, 359, 360) &equals;&equals; 1 circularDifference( 359, 0, 360) &equals;&equals; &hyphen;1 circularDifference( 180, 0, 360) &equals;&equals; 180 circularDifference( 0, 180, 360) &equals;&equals; &hyphen;180 &grave; The behavior is undefined unless `minuend &lt; modulo`, `subtrahend &lt; modulo`, and `modulo &lt;&equals; INT&lowbar;MAX &plus; 1`&period;

== Return Value

signed minimum circular distance from `subtrahend` to `minuend`

== Parameters

[cols="1,4"]
|===
| Name| Description
| *minuend*
| circular value from which `subtrahend` is subtracted
| *subtrahend*
| circular value subtracted from `minuend`
| *modulo*
| modulus at which circular values wrap to 0
|===


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