chsvlib
chsv helper source code

◆ memdecr_BE_copy()

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

Decrements 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 borrow bit.

Parameters
[out]pDestA pointer to a destination buffer to receive the result of the decrement. The capacity of the buffer must be at least cbData bytes.
[in]pSrcA pointer to the integer to decrement. 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
true if the function has borrowed from the digit cbData, i.e. if the value of the input integer is zero. Otherwise, the return value is false.

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 decrement Little-Endian integers use memdecr_LE_copy.

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

See also
memdecr_LE_copy;
memdecr_BE_inplace;
memdecr_BE;
memincr_BE;
memadd_BE;
memsub_BE;
memmul_BE;
memdiv_BE.