|
noexcept |
Increments an arbitrary precision integer specified by a vector of bytes in the Little-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 Little-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_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_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 Little-Endian byte order.
To increment Big-Endian integers use memincr_BE_inplace.