Computer number format

The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer;[citation needed] the encoding used by the computer's instruction set generally requires conversion for external use, such as for printing and display.

The representation is composed of bits, which in turn are grouped into larger sets such as bytes.

The concept of a bit can be understood as a value of either 1 or 0, on or off, yes or no, true or false, or encoded by a switch or toggle of some kind.

A person may need several nibbles for one bite from something; similarly, a nybble is a part of a byte.

[5] Octal and hexadecimal encoding are convenient ways to represent binary numbers, as used by computers.

Therefore, binary quantities are written in a base-8, or "octal", or, much more commonly, a base-16, "hexadecimal" (hex), number format.

In the decimal system, we are familiar with floating-point numbers of the form (scientific notation): or, more compactly: which means "1.1030402 times 1 followed by 5 zeroes".

If we have a negative exponent, that means the number is multiplied by a 1 that many places to the right of the decimal point.

There is a number of such schemes, the most popular has been defined by Institute of Electrical and Electronics Engineers (IEEE).

The most common scheme uses a 23-bit significand with a sign bit, plus an 8-bit exponent in "excess-127" format, giving seven valid decimal digits.

The relation between numbers and bit patterns is chosen for convenience in computer manipulation; eight bytes stored in computer memory may represent a 64-bit real, two 32-bit reals, or four signed or unsigned integers, or some other kind of data that fits into eight bytes.

Arithmetic operations can overflow or underflow, producing a value too large or too small to be represented.

In many cases a sum of reciprocal powers of 2 does not match a specific decimal fraction, and the results of computations will be slightly off.

High-level programming languages such as Ruby and Python offer an abstract number that may be an expanded type such as rational, bignum, or complex.

Mathematical operations are carried out by library routines provided by the implementation of the language.

A given mathematical symbol in the source code, by operator overloading, will invoke different object code appropriate to the representation of the numerical type; mathematical operations on any number—whether signed, unsigned, rational, floating-point, fixed-point, integral, or complex—are written exactly the same way.