开发者

what is low nibble and why the result is different by one number

I tested following code wit开发者_JS百科h ruby 1.9.2 .

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

Why the result of h* is off by 1. Also I thought nibble is 4 bits. However 68, 65, 6c, 6c and 6f are all taking one byte.


The difference between h* and H* is the order they write the halves of the byte (nibbles). h writes lower half byte first and H writes the higher half byte first.

And yes, nibble is half of the byte - that is 4 bits.

You can check out with detailed usage of pack/unpack in this post

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜