chsvlib
chsv helper source code

◆ memsub_LE_inplace()

bool Chusov::Memory::memsub_LE_inplace ( void *  pResult,
const void *  pMinuend,
std::size_t  cb 
)
noexcept

Subtracts an arbitrary-precision integer from another arbitrary-precision integer in place of the latter 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 subtrahend and on output receives the difference.
[in]pMinuendA pointer to a byte vector which holds the minuend 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 subtrahend addressed by pResult and the minuend 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 \(X - Y\) is also written to pResult in the Little-Endian byte order.

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

To produce the difference in place of a minuend, rather than subtrahend, use the memnegsub_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
memsub_BE_inplace;
memnegsub_LE_inplace;
memsub_LE_copy;
memsub_LE;
memdecr_LE;
memneg_LE;
memadd_LE;
memmul_LE;
memfmsub_LE;
memdiv_LE.