chsvlib
chsv helper source code

◆ memadd_BE_inplace()

bool Chusov::Memory::memadd_BE_inplace ( void *  pResult,
const void *  pAddend,
std::size_t  cb 
)
noexcept

Replaces an integer given by a vector of bytes in the Big-Endian order with the result of its addition with another integer.

Parameters
[in,out]pResultA pointer to a vector holding an integer to increase by the second integer pointed to by pAddend.
[in]pAddendA pointer to a byte vector with the second integer. Although the pointer is qualified with const, pAddend may address the same integer as pResult. Other than that, the pointers may not overlap.
cbA byte size of the input integers as well as the result written to pResult on output.
Returns
A value of a carry bit which results from the addition.

The addition is carried out modulo bcb, where b = 2CHAR_BIT is a number of values that a byte can represent.

All of the integers are specified with vectors in the Big-Endian byte order. That is, if n = cb - 1, and the first and the second integers are respectively specified with vectors \(V_X = \{x_0,\dots, x_n\}\) and \(V_Y = \{y_0,\dots, y_n\}\), where \(x_0\) and \(y_0\) are the first bytes of the vectors, then the respective integers are defined as \(X=\sum_{i=0}^{n}x_{n-i}\cdot b^i\) and \(Y=\sum_{i=0}^{n}y_{n-i}\cdot b^i\). The result of the addition is also written to pResult in the Big-Endian byte order.

To add up numbers given in the Little-Endian byte order use memadd_LE_inplace.

To right the sum into a separate buffer leaving the original operands unmodified, use memadd_BE_copy or memadd_BE.

See also
memadd_LE_inplace;
memadd_BE_copy;
memadd_BE;
memincr_BE;
memsub_BE;
memmul_BE;
memfmadd_BE;
memdiv_BE.