chsvlib
chsv helper source code

◆ memnegsub_LE_inplace()

bool Chusov::Memory::memnegsub_LE_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 Little-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 Little-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_i\cdot b^i\) and \(Y=\sum_{i=0}^{n}y_i\cdot b^i\). The difference \(Y - X\) is also written to pResult in the Little-Endian byte order.

To subtract numbers given in the Big-Endian byte order use memnegsub_BE_inplace.

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

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

See also
memnegsub_BE_inplace;
memsub_LE_inplace;
memsub_LE_copy;
memsub_LE;
memdecr_LE;
memneg_LE;
memadd_LE;
memmul_LE;
memfmsub_LE;
memdiv_LE.