chsvlib
chsv helper source code

◆ memneg_LE_inplace()

bool Chusov::Memory::memneg_LE_inplace ( void *  pData,
std::size_t  cbData 
)
noexcept

Replaces an arbitrary-precision integer given by a vector of bytes in the Little-Endian order with its additive inversion returning the value of the highest bit of the result.

Parameters
[in,out]pDataA pointer to a buffer which on input contains the input integer in the Little-Endian byte order. On output, the buffer receives a two's complement of the input integer with respect to 2CHAR_BIT cbData.
cbDataSize of the integer in bytes.
Returns
A value of the highest bit of the result.

The function considers the input vector to specify the integer in the Little-Endian byte order. That is, given that \(V_X = \{x_0, \dots, x_n\}\) is the input value, such that \(x_0\) is the first byte in memory of the vector, \(x_n\) is the last byte and n = cbData - 1, the input value for the operation is \(X = \sum_{i=0}^{n}x_i\cdot b^i\), where b = 2CHAR_BIT is a number of values that can be represented with one byte. To negate Big-Endian integers use memneg_BE_inplace.

To produce the result in a separate buffer leaving the original integer unchanged use memneg_LE_copy or memneg_LE.

See also
memneg_LE_copy;
memneg_BE_inplace;
memneg_LE;
memincr_LE;
memdecr_LE;
memadd_LE;
memsub_LE.