Real data type

From HandWiki - Reading time: 2 min

A real data type is a data type used in a computer program to represent an approximation of a real number. Because the real numbers are not countable, 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

Main page: Rational data type

The most general data type for a rational number stores the numerator and denominator as integers.

Fixed-point numbers

Main page: Fixed-point arithmetic

A fixed-point data type uses the same denominator for all numbers. The denominator is usually a power of two. For example, in a fixed-point system that uses the denominator 65,536 (216), the hexadecimal number 0x12345678 means 0x12345678/65536 or 305419896/65536 or 4660 + 22136/65536 or about 4660.33777.

Floating-point numbers

Main page: Floating-point arithmetic

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 a power of two for the denominator. See IEEE Standard for Floating-Point Arithmetic.

Decimal numbers

Main page: Decimal data type

Similar to fixed-point or floating-point data type, but with a denominator that is a power of 10 instead of a power of 2.




Licensed under CC BY-SA 3.0 | Source: https://handwiki.org/wiki/Real_data_type
15 views | Status: cached on July 28 2024 22:15:56
↧ Download this article as ZWI file
Encyclosphere.org EncycloReader is supported by the EncyclosphereKSF