thumb|200px|An early electromechanical programmable computer, the [[Z3 (computer)|Z3, included floating-point arithmetic (replica on display at Deutsches Museum in Munich).]]
In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a significand (a signed sequence of a fixed number of digits in some base) multiplied by an integer power of that base.
Numbers of this form are called floating-point numbers.
For example, the number 2469/200 is a floating-point number in base ten with five digits:
<math display=block>2469/200 = 12.345 = \! \underbrace{12345}_\text{significand} \! \times \! \underbrace{10}_\text{base}\!\!\!\!\!\!\!\overbrace^{\text{exponent</math>
However, 7716/625 = 12.3456 is not a floating-point number in base ten with five digits—it needs six digits.
The nearest floating-point number with only five digits is 12.346.
And 1/3 = 0.3333… is not a floating-point number in base ten with any finite number of digits.
In practice, most floating-point systems use base two, though base ten (decimal floating point) is also common.
Floating-point arithmetic operations, such as addition and division, approximate the corresponding real number arithmetic operations by rounding any result that is not a floating-point number itself to a nearby floating-point number. where he designed a special-purpose electromechanical calculator based on Charles Babbage's analytical engine and described a way to store floating-point numbers in a consistent manner. He stated that numbers will be stored in exponential format as n × 10<math>^m</math>, and offered three rules by which consistent manipulation of floating-point numbers by machines could be implemented. For Torres, "n will always be the same number of digits (e.g. six), the first digit of n will be of order of tenths, the second of hundredths, etc, and one will write each quantity in the form: n; m." The format he proposed shows the need for a fixed-sized significand as is presently used for floating-point data, fixing the location of the decimal point in the significand so that each representation was unique, and how to format such numbers by specifying a syntax to be used that could be entered through a typewriter, as was the case of his Electromechanical Arithmometer in 1920.
thumb|upright=0.7|right|[[Konrad Zuse, architect of the Z3 computer, which uses a 22-bit binary floating-point representation]]
In 1938, Konrad Zuse of Berlin completed the Z1, the first binary, programmable mechanical computer; In either case, the programmer is exposed to many of the precision pitfalls mentioned above for the portion of the program using "fast" math.
References
Further reading
- (NB. Classic influential treatises on floating-point arithmetic.)
- (NB. Edition with source code CD-ROM.)
- (1213 pages) (NB. This is a single-volume edition. This work was also available in a two-volume version.)
External links
- (NB. This page gives a very brief summary of floating-point formats that have been used over the years.)
- (NB. A compendium of non-intuitive behaviors of floating point on popular architectures, with implications for program verification and testing.)
- OpenCores. (NB. This website contains open source floating-point IP cores for the implementation of floating-point operators in FPGA or ASIC devices. The project double_fpu contains verilog source code of a double-precision floating-point unit. The project fpuvhdl contains vhdl source code of a single-precision floating-point unit.)
