["6...">

What is low nibbling and why is the result different in one number

I tested the following code with ruby ​​1.9.2.

"hello".unpack('H*')
 => ["68656c6c6f"] 
> "hello".unpack('h*')
 => ["8656c6c6f6"] 

Why the result is h*disabled by 1. Also I thought nibble is 4 bits. However 68, 65, 6c, 6cand 6fall take a single byte.

0
source share
1 answer

The difference between h * and H * is that they write half bytes (nibbles). hfirst writes the low byte, and hfirst writes the high byte.

And yes, nibble is half a byte - it's 4 bits.

You can familiarize yourself with the detailed use of the package / unpacking in this post

+2
source

All Articles