chsvlib
chsv helper source code

◆ memincr_BE_copy()

bool Chusov::Memory::memincr_BE_copy ( void *restrict  pDest,
const void *restrict  pSrc,
std::size_t  cbData 
)
noexcept

Increments an arbitrary precision integer specified by a vector of bytes in the Big-Endian order, writes the result to a separate memory buffer and returns the carry flag.

Parameters
[out]pDestA pointer to a destination buffer to receive the result of the increment. The capacity of the buffer must be at least cbData bytes.
[in]pSrcA pointer to the integer to increment. The buffer containing the integer may not overlap with the destination buffer pointed to by pDest.
cbDataA size of the input integer in bytes and the capacity of the output buffer.
Returns
Carry bit resulting from the increment.

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 = cbData - 1, the input value for the operation is \(X = \sum_{i=0}^{n}x_{n - i}\cdot b^i\) where b = 2CHAR_BIT is a number of values that can be represented with one byte. To increment Little-Endian integers use memincr_LE_copy.

The buffers pointed to by pDest and pSrc may not overlap. To increment an integral value in place use memincr_BE_inplace. The memincr_BE function, which also allows buffers of differing sizes, can increment an integer in place or with copying to a separate buffer.

See also
memincr_LE_copy;
memincr_BE_inplace;
memincr_BE;
memdecr_BE;
memadd_BE;
memsub_BE;
memmul_BE;
memdiv_BE.