Nibble
Encyclopedia
In computing
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...

, a nibble (often nybble or even nyble to simulate the spelling of byte
Byte
The byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...

) is a four-bit
Bit
A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...

 aggregation, or half an octet
Octet (computing)
An octet is a unit of digital information in computing and telecommunications that consists of eight bits. The term is often used when the term byte might be ambiguous, as there is no standard for the size of the byte.-Overview:...

. As a nibble contains 4 bits, there are sixteen (24) possible values, so a nibble corresponds to a single hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

 digit (thus, it is often referred to as a "hex digit" or "hexit").

A full byte
Byte
The byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...

 (octet) is represented by two hexadecimal digits; therefore, it is common to display a byte of information as two nibbles. The nibble is often called a "semioctet" or a "quartet" in a networking
Computer network
A computer network, often simply referred to as a network, is a collection of hardware components and computers interconnected by communication channels that allow sharing of resources and information....

 or telecommunication
Telecommunication
Telecommunication is the transmission of information over significant distances to communicate. In earlier times, telecommunications involved the use of visual signals, such as beacons, smoke signals, semaphore telegraphs, signal flags, and optical heliographs, or audio messages via coded...

 context. Sometimes the set of all 256
256 (number)
256 is the natural number following 255 and preceding 257.-In mathematics:256 is a composite number, with the factorization 256 = 28, which makes it a power of two....

 byte values is represented as a table 16
16 (number)
16 is the natural number following 15 and preceding 17. 16 is a composite number, and a square number, being 42 = 4 × 4. It is the smallest number with exactly five divisors, its proper divisors being , , and ....

×16, which gives easily readable hexadecimal codes for each value.

History

One early recorded use of the term "nybble" was in 1977 within the consumer-banking technology group at Citibank that created a pre-ISO 8583
ISO 8583
ISO 8583 Financial transaction card originated messages — Interchange message specifications is the International Organization for Standardization standard for systems that exchange electronic transactions made by cardholders using payment cards...

 standard for transactional messages, between cash machines and Citibank's data centers, in which a nybble was the basic informational unit.

The term "nibble" originates from the fact that the term "byte" is a homophone
Homophone
A homophone is a word that is pronounced the same as another word but differs in meaning. The words may be spelled the same, such as rose and rose , or differently, such as carat, caret, and carrot, or to, two, and too. Homophones that are spelled the same are also both homographs and homonyms...

 of the English word "bite". A nibble is a small bite, which in this context is construed as "half a bite". The alternative spelling "nybble" parallels the spelling of "byte", as noted in editorials in Kilobaud
Kilobaud Microcomputing
Kilobaud Microcomputing was a magazine dedicated to the computer homebrew hobbyists from the end of the 1970s until the beginning of the 1980s.-How kilobaud started:...

and Byte in the early eighties.

The nibble is used to describe the amount of memory used to store a digit of a number stored in packed decimal format
Binary-coded decimal
In computing and electronic systems, binary-coded decimal is a digital encoding method for numbers using decimal notation, with each decimal digit represented by its own binary sequence. In BCD, a numeral is usually represented by four bits which, in general, represent the decimal range 0 through 9...

 within an IBM mainframe. This technique is used to make computations faster and debugging easier. An 8-bit byte is split in half and each nibble is used to store one digit. The last nibble of the variable is reserved for the sign. Thus a variable which can store up to nine digits would be "packed" into 5 bytes. Ease of debugging resulted from the numbers being readable in a hex dump
Hex dump
In computing, a hex dump is a hexadecimal view of computer data, from RAM or from a file or storage device. Each byte is represented as a two-digit hexadecimal number. Hex dumps are commonly organized into rows of 8 or 16 bytes, sometimes separated by whitespaces...

 where two hex numbers are used to represent the value of a byte, as 16×16 = 28.

Historically, there have been cases where the term "nybble" was used for a set of bits fewer than 8, but not necessarily 4. In the Apple II microcomputer line, much of the disk drive control was implemented in software. Writing data to a disk was done by converting 256-byte pages into sets of 5-bit or, later, 6-bit nibbles; loading data from the disk required the reverse. Note that the term byte also had this ambiguity; at one time, byte meant a set of bits but not necessarily 8. Today, the terms "byte" and "nibble" generally refer to 8- and 4-bit collections, respectively, and are not often used for other sizes. The term "semi-nibble" is used to refer to a 2-bit collection, or half a nibble.

Table of nibbles

The sixteen nibbles and their equivalents in other numeral systems:
0hex = 0dec
0 (number)
0 is both a numberand the numerical digit used to represent that number in numerals.It fulfills a central role in mathematics as the additive identity of the integers, real numbers, and many other algebraic structures. As a digit, 0 is used as a placeholder in place value systems...

 
= 0oct 0 0 0 0
1hex = 1dec  = 1oct 0 0 0 1
2hex = 2dec  = 2oct 0 0 1 0
3hex = 3dec  = 3oct 0 0 1 1
4hex = 4dec  = 4oct 0 1 0 0
5hex = 5dec  = 5oct 0 1 0 1
6hex = 6dec  = 6oct 0 1 1 0
7hex = 7dec  = 7oct 0 1 1 1
8hex = 8dec  = 10oct 1 0 0 0
9hex = 9dec  = 11oct 1 0 0 1
Ahex = 10dec
10 (number)
10 is an even natural number following 9 and preceding 11.-In mathematics:Ten is a composite number, its proper divisors being , and...

 
= 12oct 1 0 1 0
Bhex = 11dec
11 (number)
11 is the natural number following 10 and preceding 12.Eleven is the first number which cannot be counted with a human's eight fingers and two thumbs additively. In English, it is the smallest positive integer requiring three syllables and the largest prime number with a single-morpheme name...

 
= 13oct 1 0 1 1
Chex = 12dec
12 (number)
12 is the natural number following 11 and preceding 13.The word "twelve" is the largest number with a single-morpheme name in English. Etymology suggests that "twelve" arises from the Germanic compound twalif "two-leftover", so a literal translation would yield "two remaining [after having ten...

 
= 14oct 1 1 0 0
Dhex = 13dec
13 (number)
13 is the natural number after 12 and before 14. It is the smallest number with eight letters in its name spelled out in English. It is also the first of the teens – the numbers 13 through 19 – the ages of teenagers....

 
= 15oct 1 1 0 1
Ehex = 14dec
14 (number)
14 is the natural number following 13 and preceding 15.In speech, the numbers 14 and 40 are often confused. When carefully enunciated, they differ in which syllable is stressed: 14 vs 40...

 
= 16oct 1 1 1 0
Fhex = 15dec
15 (number)
15 is the natural number following 14 and preceding 16. In English, it is the smallest natural number with seven letters in its spelled name....

 
= 17oct 1 1 1 1

Extracting a nibble from a byte

In C programming language:
  1. define HINIBBLE(b) (((b) >> 4) & 0x0F)
  2. define LONIBBLE(b) ((b) & 0x0F)


where b must be variable or constant of an integer data type. (Of course, if b is more than a byte wide, only one of the bytes will be considered).

For example, HINIBBLE(0xAB)

0xA and LONIBBLE(0xAB)

0xB.

In Common Lisp
Common Lisp
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 , . From the ANSI Common Lisp standard the Common Lisp HyperSpec has been derived for use with web browsers...

:

(defun hi-nibble (b)
(ldb (byte 4 4) b))
(defun lo-nibble (b)
(ldb (byte 4 0) b))

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK