Convert bytes to integers
Command takes 6 bytes (BigInt is not yet supported) and converts them into integer. Conversion supports 3 different formats:
- natural
- ones' complement
- twos' complement
Natural
In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: typically "0" (zero) and "1" (one). The base-2 numeral system is a positional notation with a radix of 2.[1]
Ones' complement
The ones' complement of a binary number is defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0s and 1s). The ones' complement of the number then behaves like the negative of the original number in some arithmetic operations. To within a constant (of −1), the ones' complement behaves like the negative of the original number with binary addition. However, unlike two's complement, these numbers have not seen widespread use because of issues such as the offset of −1, that negating zero results in a distinct negative zero bit pattern, less simplicity with arithmetic borrowing.[2]
Twos' complement
Two's complement is a mathematical operation on binary numbers, and is an example of a radix complement. It is used in computing as a method of signed number representation.
The two's complement of an N-bit number is defined as its complement with respect to 2N; the sum of a number and its two's complement is 2N. For instance, for the three-bit number 010, the two's complement is 110, because 010 + 110 = 8 which is equal to 23. The two's complement is calculated by inverting the digits and adding one.[3]
Sources:
[1] en.wikipedia.org/wiki/Binary_number
[2] en.wikipedia.org/wiki/Ones'_complement
[3] en.wikipedia.org/wiki/Two'_complement