chsvlib
chsv helper source code

◆ memcmp_BE()

int Chusov::Memory::memcmp_BE ( const void *  pX,
std::size_t  cbX,
const void *  pY,
std::size_t  cbY 
)
noexcept

Compares two arbitrary-precision integers specified with vectors of bytes in the Big-Endian order.

Parameters
[in]pXA pointer to a vector of cbX bytes representing the first integer.
cbXA byte size of the first integer.
[in]pYA pointer to a vector of cbY bytes representing the second integer.
cbYA byte size of the second integer.
Returns
A negative value, if the first integer is less then the second integer, a positive value if the first integer is greater than the second integer, otherwise the return value is zero.

Let b = 2CHAR_BIT be a number of values that can be represented using one byte, nx = cbX - 1, and ny = cbY - 1. Assuming that pX points to the vector \(V_X = \{x_0,\dots,x_{n_x}\}\), where \(x_0\) is the first element of the vector \(V_X\), and pY points to the vector \(V_Y = \{y_0,\dots,y_{n_y}\}\), where \(y_0\) is the first element of the vector \(V_Y\), the function compares the corresponding Big-Endian integers \(X = \sum_{i=0}^{n_x}x_{n_x - i}\cdot b^i\) and \(Y = \sum_{i=0}^{n_y}y_{n_y - i}\cdot b^i\) and returns a negative value, if \(V_X < V_Y\); zero, if \(V_X = V_Y\), and a positive value, if \(V_X > V_Y\).

See also
memcmp_LE.