chsvlib
chsv helper source code

◆ memadd_BE_copy()

bool Chusov::Memory::memadd_BE_copy ( void *restrict  pResult,
const void *restrict  pX,
const void *restrict  pY,
std::size_t  cb 
)
noexcept

Performs an addition of two arbitrary-precision integers given in the Big-Endian byte order and of the same size and writes the result into a separate output buffer.

Parameters
[out]pResultA pointer to the destination buffer to accept the sum.
[in]pXA pointer to the first addend.
[in]pYA pointer to the second addend.
cbA byte size of the integers pointed to by pX and pY as well as the capacity of the output buffer pResult and a number of bytes written into it.
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 in the Big-Endian byte order.

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

None of the buffers may overlap. To perform an addition in place use memadd_BE_inplace or memadd_BE.

See also
memadd_LE_copy;
memadd_BE_inplace;
memadd_BE;
memincr_BE;
memsub_BE;
memmul_BE;
memfmadd_BE;
memdiv_BE.