101

When adding or subtracting fractions, you need to find the least common multiple of the two denominators. That's an expensive operation, much more expensive than adding or subtracting floating points, which just requires shifts. Multiplication is also more expensive, because now you need to multiply two numbers instead of just one. Similarly for division. ...


59

From an interview with Dr. William Kahan, the IEEE-754 formats were based on the VAX F and G formats, which have 8 and 11-bit exponents respectively. In fact Dr. Kahan also said that previously VAX has a double precision D format which has the same 8-bit exponent as the single precision F format which proved too limited in practical use, therefore DEC had to ...


55

As far as I’m aware, the last FPU-less x86-compatible CPU which could still be considered general-purpose is the Vortex86SX, released in 2007 and still available now. This is a Pentium-class CPU, capable of running any Pentium code which doesn’t require an FPU. It is targeted at embedded applications, with up to 512 MiB of RAM, and includes a PCI bus, USB, ...


52

My question is, why not use fractions? Quick answer: Too much code needed Dynamic storage needed Long representation even for simple numbers Complex and slow execution And most prominent: Because floating point is already based on fractions:Binary ones, the kind a binary computer handles best. Long Form: The mantissa of a floating point number is a ...


47

The opcodes in your list are all only 16 bits (plus the extra bytes for address calculation) and you'll notice that they all begin (in hex) with Dx where x >= 8. This is because, to the 8086, any instruction whose first byte has the bit pattern 11011xxx was deemed to be an 8087 coprocessor instruction. When the 8086 encountered a floating point opcode, it ...


42

Yes. For example, the C math library has had full support for long double, which on x87 was 80 bits wide, since C99. Previous versions of the standard library supported only the double type. Conforming C and C++ compilers also perform long double math if you give the operations a long double argument. (Recall that, in C, 1.0/3.0 divides a double by ...


42

TL:DR: Yes, most C/C++ compilers other than MSVC expose an 80-bit IEEE754 Extended Precision format (x87, 68881) as long double, and some implementations of other languages have it as REAL10 or whatever name. But no, none of the major C compilers had an option to force promoting double locals/temporaries to 80-bit even across spill/reload, only keeping them ...


42

The floating-point routines for Microsoft BASIC were written by Monte Davidoff in 1975, originally for the Altair, which used an Intel 8080 CPU. The source code had been lost for years, until Bill Gates’ former tutor discovered a copy in 2000 that had fallen behind his file cabinet two decades before. Davidoff needed to invent his own floating-point format, ...


33

But why was the 8087 designed such that it needed a special socket? Because the 8087 is a processor EXTENSION, not another CPU. The 8087 has, except for a few lines, exactly the same signals and pinout as the 8086/88. The socket is, except for 4(?) lines, a one-on-one duplicate of the CPU socket. This includes signals that need to be connected between both ...


33

The range of intermediate results. The Java Language Specification, 2nd Ed. relaxed the evaluation rules for floating-point expressions by introducing the notion of an ‘FP-strict’ expression, defined as follows (§15.4, p. 319): Within an FP-strict expression, all intermediate values must be elements of the float value set or the double value set, implying ...


31

The documented way to detect an x87 FPU is to attempt to initialise it, and then read its control word (FPU_STATUS must be set to some non-zero value first): FNINIT FNSTSW WORD PTR [FPU_STATUS] This uses the non-waiting variants, otherwise the CPU will wait for a non-existent FPU to respond. If the status word is not 0 after this, no FPU is installed — the ...


31

As far as I am familiar with the genesis of the IEEE-754 floating-point standard from the literature, G. W. Stewart never looked at implementation cost for the support of gradual underflow. He was tasked with examining its claimed advantages to floating-point computation from a numerical analysis viewpoint. Charles Severance, "IEEE 754: An Interview ...


27

There is a mathematical problem with your idea. If you choose to store fractions with a fixed-length numerator and denominator, that's works fine until you try to do arithmetic with them. At that point, the numerator and denominator of the result may become much bigger. Take a simple example: you could easily store 1/1000 and 1/1001 exactly, using 16-bit ...


23

When you have a small transistor budget, it is considerably easier to design your circuitry around a single representation format - the most capable one - and treat converting other formats to and from it as a separate problem. That's how the 8087 and 68881 were both designed. Today, there are enough transistors sloshing around in the average CPU that ...


23

Using a 32 bit signed mantissa and 8 bit unsigned exponent has one major advantage: You can re-use 32 bit integer math functions for operating on the mantissa. That re-use saves memory. It may even be possible to optimize the 8 bit exponent maths if character maths are supported, as characters are typically stored as 8 bit unsigned ASCII. The original ...


20

I worked for Borland back in the days of the 8086/8087. Back then, both Turbo C and Microsoft C defined long double as an 80-bit type, matching the layout of Intel's 80-bit floating-point type. Some years later, when Microsoft got cross-hardware religion (maybe at the same time as they released Windows NT?) they changed their compiler to make long double a ...


19

Floating-point isn't just about representing numbers that have fractional parts. It's also about representing numbers that are very large, or very small, in a way that allows extra range by sacrificing precision. Consider these examples: 1,000,000,000,000,000,000,000,000,000,000 (1 with 30 zeros after). This number can be reasonably stored in floating-...


18

The ZX Spectrum has two formats for storing numbers, both 40 bits, or five bytes. Jup, like many other machines - one for float and one for integer. The second is some kind of 16-bit integer format, Not some kind, but the integer format. fluffed up to fit the same amount of space as a float. Which was done to make variable memory management easy. ...


18

This example reveals a rounding error under Commodore BASIC V2.0: A=0.3:B=0.6:IF A+B<>0.9 THEN PRINT A+B-0.9 Running this on a C64 yields a difference of 2.32830644e-10. Other pairs that fail are 0.4+0.5, 0.6+0.1 and 0.8+0.1. Please note that also the order in which the numbers are summed up affects the result. 0.6+0.1-0.7 yields a difference, ...


18

Full disclosure: I worked on the x87 FPU of a 486-class CPU at a math-coprocessor company in the early 1990s and thereafter worked at AMD, where I was on the 3DNow! design team and the design team for the FPU of the AMD Athlon processor (also known as K7). The x87 FPU never acquired a flush-to-zero mode. In fact, denormal support was one of the major ...


17

All Intel x86 CPUs since the 80486 line have included floating point instructions, i.e. everything from the Pentium* onward. So the last Intel processor to lack an on-board floating-point unit (FPU) was the 80486SX (and the embedded 80486GX). Other manufacturers, who made 486-compatible processors, continued making non-FPU chips, aiming for the budget ...


17

The first major console to incorporate an IEEE 754 floating point unit would be the N64. The main use of them in games is for the mathematical operations involved when transforming in-game 3D objects into 2D shapes for rendering on the display. An important secondary use is for games that have physics engines. Previous consoles typically did this by means ...


17

It's not a power of 2, not a nice round number But it is :-) 1 byte exponent (with an assumed 1 bit always equal to one), 4 bytes mantissa, at least on the ZX Spectrum – see the ZX Spectrum manual. And since the mantissa and exponent are processed individually, the mantissa is a nice power of 2. Granted, this is less of an advantage without full 32 bit ...


16

Well, the first thing to remember about these binary formats you're talking about (there were also decimal formats) is that they are the interchange formats; it's not required that hardware, or even software, use these for internal calculations. It's perfectly reasonable for an implementation to use an entire separate byte for the sign and one or more ...


15

There are nearly endless benchmarks (see a short list of relevance at Benchmark Programs and Reports on the Top500 site) and it may need a bit of work to understand each benchmark's implications (see Benchmark Tutorial, in IEEE Micro 1989, or An Overview of Common Benchmarks in Computer 12/1990). Benchmarking will always give only a rough estimation, so all ...


14

Point by point. faster addition/subtraction No: 8/15 + 5/7 is evaluated as 131/105 [(8*7 + 15*5)/(7*15)], so 3 multiplications for one single addition/subtraction. Plus possibly reduction easier to print No: you have to print a human readable string of digits. So you must transform 131/105 to 1.247... Or are you proposing to simply display the fraction? Not ...


14

The MC68882 was relatively well-regarded among 1980s FPUs. Digging out accurate timing information takes some effort, but it appears that handling denormalised values was only moderately burdensome for this FPU. In the context of a register-to-register FADD already taking several dozen clock cycles: Taking a denormalised extended-precision source operand ...


14

While this may cover many ways of overflow (from integer and counter all the way to record, I assume the Overflow in question is about floating point, which more precisely means over/underflow of the exponent. The exact handling varies widely between compilers and machines. Fortran 77 did not make any assumptions here (AFAIK), it at all, it was expected that ...


13

There's a great and much detailed description at the C64 Wiki (*1) describing the basic structures and workings, as well as all functions involved to use the ROM routines for floating point (*2) Cookbook: Use GIVAYF to convert a 16 Bit number in A:Y into an FP in FAC If multiple numbers are involved, move FAC to memory using MOVMF Repeat for all numbers Do ...


13

Some modern programming languages do have a Rational or Fractional type, so your idea has merit. However, there are and were several different problems with it. It's worth noting that, even on systems where floating-point also needed to be implemented in software, fractional math wasn't widely-used as an alternative. Some possible reasons that applied at ...


Only top voted, non community-wiki answers of a minimum length are eligible