Real Data Type
   HOME

TheInfoList



OR:

A real data type is a
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
used in a
computer program A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
to represent an approximation of a
real number In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
. Because the real numbers are not
countable In mathematics, a Set (mathematics), set is countable if either it is finite set, finite or it can be made in one to one correspondence with the set of natural numbers. Equivalently, a set is ''countable'' if there exists an injective function fro ...
, computers cannot represent them exactly using a finite amount of information. Most often, a computer will use a rational approximation to a real number.


Rational numbers

The most general data type for a
rational number In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (for example, The set of all ...
(a number that can be expressed as a fraction) stores the numerator and the denominator as
integers An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
. For example 1/3, which can be calculated to any desired precision. Rational number are used, for example, in Interpress from
Xerox Corporation Xerox Holdings Corporation (, ) is an American corporation that sells print and digital document products and services in more than 160 countries. Xerox was the pioneer of the photocopier market, beginning with the introduction of the Xerox ...
.


Fixed-point numbers

A fixed-point data type uses the same, implied, denominator for all numbers. The denominator is usually a
power of two A power of two is a number of the form where is an integer, that is, the result of exponentiation with number 2, two as the Base (exponentiation), base and integer  as the exponent. In the fast-growing hierarchy, is exactly equal to f_1^ ...
. For example, in a hypothetical fixed-point system that uses the denominator 65,536 (216), the hexadecimal number 0x12345678 (0x1234.5678 with sixteen fractional bits to the right of the assumed radix point) means 0x12345678/65536 or 305419896/65536, 4660 + the fractional value 22136/65536, or about 4660.33777. An
integer An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
is a fixed-point number with a fractional part of zero.


Floating-point numbers

A floating-point data type is a compromise between the flexibility of a general rational number data type and the speed of fixed-point arithmetic. It uses some of the bits in the data type to specify an exponent for the denominator, today usually power of two although both ten and sixteen have been used.


Decimal numbers

The decimal type is similar to fixed-point or floating-point data type, but with a denominator that is a
power of 10 In mathematics, a power of 10 is any of the integer powers of the number ten; in other words, ten multiplied by itself a certain number of times (when the power is a positive integer). By definition, the number one is a power (the zeroth power ...
instead of a power of 2.


See also

*
Binary number A binary number is a number expressed in the Radix, base-2 numeral system or binary numeral system, a method for representing numbers that uses only two symbols for the natural numbers: typically "0" (zero) and "1" (one). A ''binary number'' may ...
* Decimal number * Hexadecimal number * IEEE Standard for Floating-Point Arithmetic


References

{{DEFAULTSORT:Real Data Type Data types Computer arithmetic