|
noexcept |
Increments an arbitrary precision integer specified by a vector of bytes in the Big-Endian byte order doing it in place or writing the result into a separate buffer with zero-extension or contraction to fit the buffer and returns the resulting carry flag.
[out] | pDest | A pointer to the destination buffer which receives the result of the increment modulo bcbDest , where b = 2CHAR_BIT is a number of values that can be represented using one byte. That is, the capacity cbDest of the buffer can be different from the size of the input value: if the capacity is greater than cbSrc , the input value is zero-extended to cbDest bytes before the increment; otherwise, if the capacity is less than the size of the input integer, the necessary number of high-order bytes of the result of the increment are discarded. |
cbDest | Capacity of the output buffer pointed to by pDest as well as the size of the resulting integer. | |
[in] | pSrc | A pointer to the input integer to increment. Both pointers, pSrc and pDest , may refer to the same buffer in memory, in which case the operation is performed in place. Other than that, the buffers may not overlap. |
cbSrc | A size of the input integer in bytes. |
The function considers the input vector to specify the integer in the Big-Endian byte order. That is, given that \(V_X = \{x_0, \dots, x_n\}\) is the input vector pointed to by pSrc
, such that \(x_0\) is the first byte in memory of the vector, \(x_n\) is the last byte and n = cbSrc - 1
, the input value for the operation is \(X = \sum_{i=0}^{n}x_{n - i}\cdot b^i\).
The operation is performed modulo bcbDest
. That is, before the increment takes place the input value \(X\) is zero-extended or contracted to fit the buffer of cbDest
bytes. The input value is therefore transformed to the value \(X' = \sum_{i=0}^{m}x'_i\cdot b^i\), where m = cbDest - 1
, \(x'_i = x_{n - i}\) if \(0 \le i \le n\), and \(x'_i = 0\) otherwise. The value \(X'\) is then incremented and written into the destination buffer pDest
, again, in the Big-Endian byte order (after the increment the \(m\)-th byte of the result is written to pDest[0]
).
To increment Little-Endian integers use memincr_LE_inplace.