Questions tagged [nibble]

A unit of information usually corresponding to 4 bits.

In computing, a nibble (occasionally nybble or nyble to match the spelling of ) is a four- aggregation of information.[Wikipedia]

Although less common than the , some computer architectures use the nibble as the primary unit of computation and information storage.

54 questions
17
votes
4 answers

Best way to get two nibbles out of a byte in javascript?

I'm parsing a binary file in javascript that is storing two pieces of information per byte, one per nibble. The values are, of course, 0-16 and 0-16. In all other parts of the file format, each byte represents one piece of information, so I have…
Geuis
  • 41,122
  • 56
  • 157
  • 219
7
votes
3 answers

Is there a .NET data-type smaller than a byte?

How about a Nibble etc.
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
6
votes
3 answers

Why are binary numbers almost always grouped in 4 bits?

I'm learning ARM so going back to basics with binary/hex arithmetic and it got me thinking about how binary numbers are usually presented in groups of 4, e.g. 1111 1110 1101 1100 Is there a particular reason why it's done this way? Seeing as we…
mike
  • 2,073
  • 4
  • 20
  • 31
4
votes
5 answers

C: Implementing array of nibbles

I am trying to stuff 16 unsigned values into 8 bytes (64 bit), and access them using an array-like syntax. Every entry in the "array" will be one nibble - 4 bit long. (The values I plan to store are never bigger than 15). My first attempt was…
so.very.tired
  • 2,958
  • 4
  • 41
  • 69
4
votes
1 answer

PHP to python pack('H')

I'm translating an authentication library, written in PHP to Python. It's all legacy code, the original devs long gone. They used PHP's 'pack' command to transform a string into hex using the 'H' flag. PHP's documentation describes this as 'Hex…
stakolee
  • 893
  • 1
  • 7
  • 20
3
votes
1 answer

Usage of nibble in Programming

Simple question as title says. I saw some questions on StackOverflow(and in internet) about use cases of nibbles, but I don't understand why do we need to use nibbles. I mean byte is the smallest unit of memory in computing so performing operations…
Chestera
  • 667
  • 2
  • 13
  • 22
3
votes
0 answers

Converting nginx uuid from hex to Base64: how is byte-order involved?

Nginx can be configured to generate a uuid suitable for client identification. Upon receiving a request from a new client, it appends a uuid in two forms before forwarding the request upstream to the origin server(s): cookie with uuid in Base64…
ivan
  • 6,032
  • 9
  • 42
  • 65
3
votes
2 answers

Setting a nibble of a 32-bit integer to a certain value

I am stuck on how to replace a 4-bit value to a certain position of an original 32-bit integer. All help is greatly appreciated! /** * Set a 4-bit nibble in an int. * * Ints are made of eight bytes, numbered like so: * 7777 6666 5555 4444…
James Carter
  • 387
  • 2
  • 6
  • 18
2
votes
2 answers

Python split byte into high & low nibbles

I am trying to send and receive rs232 data using pyserial but I don't understand how to properly send the correct data. What little information I have explains the data string and says that it should be split into high and low nibbles. The…
Spacefigher
  • 45
  • 1
  • 1
  • 5
2
votes
1 answer

Effienctly unpack mono12packed bitstring format with python

I have raw data from a camera, which is in the mono12packed format. This is an interlaced bit format, to store 2 12bit integers in 3 bytes to eliminate overhead. Explicitly the memory layout for each 3 bytes looks like this: Byte 1 = Pixel0 Bits…
Dschoni
  • 3,714
  • 6
  • 45
  • 80
2
votes
2 answers

Moving a "nibble" to the left using C

I've been working on this puzzle for awhile. I'm trying to figure out how to rotate 4 bits in a number (x) around to the left (with wrapping) by n where 0 <= n <= 31.. The code will look like: moveNib(int x, int n){ //... some code here } The trick…
Shaw
  • 169
  • 1
  • 3
  • 12
2
votes
1 answer

Get two nibbles from a byte in Ruby

What's the easiest way to get two nibbles (as Integers) from a byte in Ruby?
Mike
  • 23
  • 2
1
vote
5 answers

Nibble shifting

I was working on an encryption algorithm and I wonder how I can change the following code into something simpler and how to reverse this code. typedef struct { unsigned low : 4; unsigned high : 4; } nibles; static void crypt_enc(char…
Jonathan Lima
  • 21
  • 1
  • 4
1
vote
1 answer

Change values in a variable based on a conditional value in R

I want to change values in my username variable but only when they meet a condition set from the variable chatforum. For example, I want all instances of users called "Alex" from Canadian chatrooms to be relabeled as "AlexCA": # mock…
Essan Rago
  • 77
  • 1
  • 5
1
vote
0 answers

Do signed nibbles make any sense?

I wrote this helper method to unpack a byte onto nibbles: public static void Deconstruct(this byte value, out byte nibble1, out byte nibble2) { nibble1 = (byte) ((value >> 00) & 0x0F); nibble2 = (byte) ((value >> 04) & 0x0F); } Then…
aybe
  • 15,516
  • 9
  • 57
  • 105
1
2 3 4