chsvlib
chsv helper source code

◆ memnegsub_BE_inplace()

bool Chusov::Memory::memnegsub_BE_inplace ( void *  pResult,
const void *  pSubtrahend,
std::size_t  cb 
)
noexcept

Subtracts an arbitrary-precision integer from another arbitrary-precision integer in place of the former and returns the resulting borrow bit. The operands and the result are considered to be in the Big-Endian byte order.

Parameters
[in,out]pResultA pointer to a buffer which on input holds the minuend and on output receives the difference.
[in]pSubtrahendA pointer to a byte vector which holds the subtrahend of the operation.
cbByte size of the operands and the capacity of the output buffer.
Returns
true if a borrow has taken place and false otherwise.

The subtraction 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, the minuend addressed by pResult, and the subtrahend addressed by pMinuend 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 difference \(Y - X\) is also written to pResult in the Big-Endian byte order.

To subtract numbers given in the Little-Endian byte order use memnegsub_LE_inplace.

To produce the difference in place of a subtrahend, rather than minuend, use the memsub_BE_inplace function.

To produce the difference in a separate buffer and leave the input integrals unmodified, use memsub_BE_copy or memsub_BE.

See also
memnegsub_LE_inplace;
memsub_BE_inplace;
memsub_BE_copy;
memsub_BE;
memdecr_BE;
memneg_BE;
memadd_BE;
memmul_BE;
memfmsub_BE;
memdiv_BE.