Skip to content Skip to sidebar Skip to footer

Why Is Bit-buffer And Buffer Giving Me Different Output?

I'm trying to understand what is going on with the following code. console.log(buffer); >>>

Solution 1:

First of all, buffers are not grouped into hex digits but into octets (bytes), so you should put the bits in groups of 8 not 4.

Each of those groups is simply reversed. That's because the human-readable representation is big-endian, and when you read the bit at index 0 that's the rightmost. So if you are reading them bit-by-bit from your stream, you read each byte from the right to the left.

Post a Comment for "Why Is Bit-buffer And Buffer Giving Me Different Output?"