4

Fractions like a third, a fifth, a tenth and so on cannot be precisely represented in binary, because those would be recurring fractions and so would never fit in a (reasonable) data structure. And some fractions like a third, while impossible to represent precisely in decimal, can easily be represented precisely in another radix, say duodecimal. So using a particular radix solves the problem of representing fractions in a finite amount of space, but each radix does this only for certain fractions.

Apparently the Babylonians and the Mayans counted in base-60, a number which has the beautiful property of having many divisors. Also, it's a number which fits quite neatly in 6 binary digits, and overflow detection wouldn't be that hard to implement (a small number of AND gates is all that's needed). Base-240 might be another good choice for similar reasons. The advantage of a system like that is that common fractions 1/3, 1/5, 1/7 etc can be represented exactly, which could lead to fewer rounding errors.

Now as to early computers, many used base-2 (that's the same thing as binary), but some used base-10, some used base-3, and my supposition is that a floating point implementation on these computers would naturally have different characteristics in the precision of certain (useful) non-integers. So did any early computers use another base than binary, in order to improve the accuracy of rational arithmetic? Would that have been worth doing?


This question has been marked as a possible duplicate of Why not use fractions instead of floating point?. To clarify the difference, that question is about representing numbers as i+(e/d), which is what a fraction is. This question is about representing numbers as m×bᵉ, which is a traditional floating point, only varying b.

  • 4
    I think the basic assumption that you could improve precision generally by using a different radix is wrong. You can only improve precision of specific values (like 1/3 for base 3, tradeoff is: now you can't properly express 1/2). What would be such preferred "certain (useful) non-integers" you want to express exactly? I don't see them for a general-purpose computer. Also, there's technical limits - a ternary computer was proven to be doable, anything beyond that probably not. If you want that, you'd have to look into analog computing, but that's far from general purpose. – tofro Feb 11 at 10:30
  • 1
    @tofro for a given value, you can increase the likelyhood that it may be represented precisely by increasing the number of divisors that the radix has. Base 3 is a bad choice because 3's a prime number and so has no divisors, Base 10 is a relatively poor choice since it has only two (2 and 5), base 60 is a good choice since it has many (2, 3, 4, 5, 6, 10, 12, 15 etc). So in base60 many values may be represented precisely which cannot be represented precisely in decimal or binary. – Wilson Feb 11 at 10:38
  • 3
    IBM hexadecimal floating-point isn't quite the same idea, but its "wobbly precision" suggests possible problems with the approach. – John Dallman Feb 11 at 11:32
  • 2
    Off topic. The stock market used to measure prices in points, half points, quarter points, etc. This works well for binary floating point numbers, but less well for decimal fractions. When they decimalized the stock market quote system, they actually made it harder to keep creeping rounding errors under control. – Walter Mitty Feb 11 at 21:27
  • 1
    Is this really a duplicate? It seems to me this is asking about binary floating point vs. using a radix that can can represent some values more accurately as "decimal" floating point (see Wikipedia, et al) in early computers. There is even a paper out there that describes an interleaved radix system for high-precision computation. Skimming through that other Q&A I see mention of how rationals can be approximated, but no mention of the pros and cons of radix-based representation (and why they were are were not used in early systems). My inclination is to refer this to Maths.SE or keep it. – user12 Feb 12 at 15:58
7

Beside binary floating point and decimal FP only IBM's sedecimal (hex) FP found wider usage. To a practical extend the base-16 FP is only a variation of binary.

So did any early computers use another base than binary, in order to improve the accuracy of rational arithmetic?

Yes, decimal.

Decimal offers the advantage of producing exactly the same precision inherent to our human arithmetic. A consistent result with a known number of valid digits is in reality usually more relevant than a perfect one. For decimal FP after each calculation the number of valid (decimal) digits is well known and without any doubt. That's why even binary machines often implement BCD, as this, in addition with fixed point notation guarantees results following the well set rules for decimal numbers.

The mentioned base-16 is more of a sideline of binary FP, as it's precision wise comparable (*1). It was introduced due to the structure of the machine implemented for (*2). It had already a nibble based move hardware to handle BCD. Basically a barrel shifter working in multiple of 4. Using it to align FP values for computation and normalizing them later would result in optimal speed without the need for adding a bitwise barrel shifter (*3).

So using a particular radix solves the problem of representing fractions (*4) in a finite amount of space, but each radix does this only for certain fractions. [...] Base-240 [...] The advantage [...] is that common fractions 1/3, 1/5, 1/7 etc can be represented exactly, which could lead to fewer rounding errors.

And any base used can only cover a very small number of common fractions. By looking close you'll notice, that it comes down to prime numbers (*5), and even base-240 (*6) only includes the first 3 primes: (1,) 2,3 and 5. Already number 7 you cite isn't in there, thus producing precision errors.

Only a use of variable base FP, one where every number is made to a best fitting base, would maybe lower precision errors. Much the same way a fraction based system does circumvent the problem by using an intermediate format. Except, a variable base format would not only increase calculation cost to a similar extreme, it will also work only with a subset, as only one fraction has to be used (and found first).

Last, but maybe even more important, when it comes to outputing the result, no matter what system with a single radix we use (except 10), conversion errors will again be introduced, as we surely prefer a base 10 output, don't we? And any meaningful statement about the precision (valid digits) will have to be made in that radix, not in base-10 as we would like it to have.

Conclusion: For human computer usage there are only two meaningful FP representations:

  • Binary (Base-2) to create the most simple computer and
  • Decimal (Base-10) to create one operating with the same precision errors we are used to/expect.

*1 - There is a precision 'wobble', as due the nibble (4 bit) nature the number of significant binary digits varies from n-3 to n with n being the number of bis assigned to the mantissa. Thus a 32 bit float with a 24 bit (6 nibble) mantissa has 21..24 bit precision. The price to be payed for the hardware shortcut. But not a big one either, as the default format wasn't 32 but 64 bit anyway.

*2 - IBM /360 if you have to ask :))

*3 - It's these details why I'm so impressed with Mr. Amdahl's work.

*4 - Looks like you're still toying with this idea, don't you? :))

*5 - Since any number can be factorized into primes, we only need to look at primes.

*6 - Using that example is quite nice, as it points to the blinds we carry without even noticing. We're so used to binary computers, that we try to fit everything in this format - even when asking for non binary solutions. A similar shortcut is the often used argument, that decimal would be spacewise inefficient as it needs four bits to store a digit. On a decimal computer storage wouldn't be binary - it would be of course decimal, with each decimal-bit holding 10 values (much like today's flash cells holding 8 or more values). A decimal-byte on such a machine may be made of 2 decimal-bits, quite sufficient to hold a character.

Thinking of it, a modern decimal computer would be most likely be base-5, with two bits per decimal digit and 4 per decimal-byte and 20 per decimal word. With the exception of the sense amplifiers, such a computer will way more compact as a binary.

In any case, such a machine would most definitely not waste space storing decimal numbers - rather the other way around when it comes to binary - but than again, who would care about binary anyway .))

  • If you look into actual adoption of BCD, this was mainly used in commercial software calculating with currency - Scientific software, on the other hand, was rarely using BCD arithmetic, even if you'd assume they'd need high-precision calculations. – tofro Feb 11 at 19:08
  • 1
    @tofro The question was about FP, not BCD, wasn't it? – Raffzahn Feb 11 at 20:24
  • 2
    The financial world cares a lot more about precise consistency between human calculations and computer calculations than the scientific world. – Peter Green Feb 13 at 18:32
2

The ENIAC (one of very first electronic computers, depending on definition) was a decimal computer (used decimal arithmetic accumulators, implemented with vacuum tubes).

  • Possible reasons include that the error metric was a comparison of direct accumulator display results against human, pencil and paper, arithmetic, not against theoretical infinite precision results. – hotpaw2 Feb 11 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.