[#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. == Synopsis Declared in `<bdlcc_fixedqueueindexmanager.h>` [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 ‐ subtrahend`) where minuend and subtrahend are both "circular values", meaning they are part of a non‐euclidean number line where the value wrap around to 0 at the specified `modulo`. 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.e., the minimum "distance" between the points on the number circle), where increments are a positive difference, and decrements are a negative difference. If the number of increments and number of decrements between `minuend` and `subtrahend` are equal, `minuend ‐ subtrahend` is returned. For example, for a hypothetical compass, [0, 360):] ` circularDifference( 0, 359, 360) == 1 circularDifference( 359, 0, 360) == ‐1 circularDifference( 180, 0, 360) == 180 circularDifference( 0, 180, 360) == ‐180 ` The behavior is undefined unless `minuend < modulo`, `subtrahend < modulo`, and `modulo <= INT_MAX + 1`. == 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]#