What is Decimal64 from Decimal floating point from IEEE 754 or exact decimal floating point numbers in computer

*All examples here are considered for 64-bit numbers (all examples are similar for other values), unless otherwise noted.

More than 90% of all programmers know what ordinary floating point numbers are: binary32/binary64/binary128, they are often called float, double, etc. Accordingly, there is a lot of information about why 0.1 cannot exist in binary form, that with a large number of significant digits there will be a lack of precision, even if you do not go beyond 16 digits, but they are fast… But there is almost no information about the fact that an excellent solution that preserves all the advantages and corrects the disadvantages exists, even in the most updated floating point standard IEEE 754-2008 for more than 15 years, this decimal floating point (DFP).

First, let's remember the structure of a regular binary64: 1 sign bit, 11 exponent bits, 52 mantissa bits. Let me show you a picture:

This makes it much clearer

This makes it much clearer

Previously, an attempt to create a decimal system for floating numbers led to a glutton, which, the more memory you give it, the more it will eat BCD, you encoded numbers in tetrads, but the main problem is that the fourth bit was used only for three numbers, because of this, even the binary mantissa for irrational numbers was more accurate, since it allowed encoding more decimal digits: 16.3 versus 13.

Bit loss was noticed in the late 1960s, so the Chen-Ho encoding was created, which encoded 3 decimal digits in 10 bits, after 2002 it was improved and turned into a densely packed decimal fraction or more correctly Densely packed decimal (DPD) all the advantages were preserved and one more was added the first numbers in this encoding were the same as in BCD, this simplified the conversions, so it was included in the updated IEEE 754 standard, there was also another Binary Integer Decimal (BID). The losses were at least some in this case only for 10 bytes: 1000 versus 1024 decimal digits, but show me a real application of such numbers with 80 bits in the mantissa (!).

Here is an illustration of the encoding of numbers in BCD, Chen-Ho, DPD:

There is encoding, there are floating numbers, so why not combine them? This is what was done: we got Decimal floating-point (DFP), they can use either DPD or BID (there is no particular difference).

Let's compare binary64 vs decimal64 (for the other options everything will be similar):

  1. The number of significant digits is 16.3 and 16 is parity.

  2. Exponent range 10-308 up to 10308 and 10-383 up to 10384 – Decimal64 wins here.

  3. Execution speed: The first answer that comes to mind is that binary is faster. But here's something very interesting: binary doesn't calculate ALU (it simply can't) but a separate subprocessor (FPU), so the same can be done for Decimal (there's only an implementation in microcode now). It's like comparing binary and ternary computers, while emulating the latter in software. Parity.

Summary: Decimal floating point is very interesting and advantageous because of the ability to represent exactly the decimal number system and a larger range of exponents at the same time, replacing binary, it is not more difficult to implement than FPU, and there will be more advantages. Why they did not replace it in PCs (my opinion): although it is in IEEE 754, few people know about it, and PC processor manufacturers are too lazy to change it, since there is no request, and there is no request, because there are no implementations and even in C++ there is no Decimal, it turns out to be a vicious circle. But this is my opinion, I will be glad to read comments that will give a different point of view, their pros and cons of Decimal, and why there is no hardware implementation in personal computers.

The purpose of this article is to introduce more people to this amazing technology, so without a lot of formulas etc. :).

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *