Mixed decimal-binary format vs IEEE754

    In the previous topic , we considered a new format for the representation of decimal floating-point numbers, which we called mixed decimal-binary format (SDFD).

    This format allows you to perform arithmetic calculations on a computer without using BCD with the same accuracy as if the calculations were performed manually.
    Recall that a mixed decimal binary format (SDF) is a format for representing decimal floating point binary code in which the integer mantissa is the binary equivalent of its decimal value, and the exponent is the binary equivalent of the power of 10. A real number in SDFF is represented as

    F = S M 2 10 e


    Where M 2 and e are binary integers. The binary equivalent of a decimal number means the binary code of this decimal number in the selected format. By decimal equivalent of a binary number is meant the decimal code of this binary number.

    Let's compare the basic properties of floating-point numbers, which are presented in the IEEE754 standard and SDF. For simplicity, consider the 16-bit machine word. This is the so-called half-precision format . Comparison results can be easily scaled to the case of single and double precision exchange formats.

    We split the 16-bit binary word into the following fields: S, e, m. Where S is the digit digit of the number, e is 5 bits of the shifted exponent, m is 10 bits of the binary equivalent of the decimal mantissa of the number. The maximum binary value of the shifted exponent written in a 5-bit register will be emax = 11111, or in decimal form emax = 31. The offset in this case is 15.

    So

    1 . The mantissa of a packed number in IEEE754 contains the fractional part of the mantissa of a number.

    The mantissa of a number in SDF is a binary integer.

    2 . Normalized IEEE mantissa in the unpacked form is 1.xxxxxxxxxx. Where x is any binary digit.

    Since the mantissa is normalized, its whole part in the unpacked form is always equal to 1. This unit can be not stored in the machine’s memory. Thus, in the unpacked form, taking into account the virtual unit, the mantissa will have 11 bits.

    The normalized mantissa in SDFF is a whole binary number equal to the equivalent of a decimal number, which in our case is represented by three digits: UХХ. Where U is any decimal digit not equal to zero. X is any decimal digit.

    In 10 bits of the mantissa, a maximum decimal number of 1023 can be represented. All integers less than 1023 can be guaranteed to be represented by 10 bits. Therefore, all decimal integers with a mantissa ≤ 999 can be accurately represented by 10 bits of the mantissa.


    3 . In IEEE754, the maximum normalized binary mantissa is Mmax = 1.1111111111 = 1.9990234375. The

    guaranteed number of valid digits that can be represented by a binary 11-bit mantissa is 3 .

    The maximum normalized decimal mantissa in SDDF is equal to Mmax = 999 or in binary form Mmax = 1 111 100 111. The decimal equivalent of the mantissa consists of 3 decimal digits. Consequently, the three-digit mantissa in our example is accurately represented in SDF 3 by significant decimal digits.

    four. In IEEE754, the minimum normalized value of the mantissa, with emin = 0, will be: Mmin = 1.0

    The minimum normalized mantissa in SDF, with emin = 0, is equal to a decimal number Mmin = 100. Or in binary form Mmin = 0001100100.

    5 . The maximum positive decimal number that can be written in IEEE754 format with the offset exponent is

    Fmax = 2 ^ emax * Mmax = 2 ^ 31 * 1.9990234375 = 4292870144 = 4.292870144 * 10 ^ 9. However, in the standard, the maximum number is the number Fmax = 2 ^ emax = 2 ^ 31 = 4294967296 = 4.294967296 * 10 ^ 8. Numbers> 2 ^ 31 are considered equal plus infinity.

    The maximum positive decimal number that can be accurately recorded in SDDF format with a shifted exponent will be

    Fmax = 10 ^ emax * Mmax = 10 ^ 31 * 999 = 9.99 * 10 ^ 33


    6. The range of approximate normalized numbers that can be represented in IEEE format will be

    Fmax / Fmin = 2 ^ 31 = 4294967296 = 4.294967296 * 10 ^ 8

    The range of exact numbers that can be represented in SDDF format will be equal to
    Fmax / Fmin = 9.99 * 10 ^ 31


    7 . The increment step of a binary number in IEEE when the exponent is biased (emin = 0) is equal to:
    h = 0.0000000001 = 2 ^ -10 = 0.0009765625 The

    step change of the decimal number in SDPF is at the displaced exponent (emin = 0):
    h = 00001100100 = 100


    8. In IEEE754, with an exponential biased, if e = 0, then all numbers <1.0 are subnormal. The smaller the subnormal number, the less accurately it represents its decimal equivalent. Special algorithms are required for encoding subnormal numbers into an exchange format, decoding from an exchange format, and also special traps for determining subnormal numbers in arithmetic operations.

    There are no subnormal numbers in SDDF. All numbers are represented with precision, in our case, up to 3 significant digits.

    9 . With an unbiased exponent, the maximum normalized positive decimal number that can be written in the IEEE754 format will be equal to
    Fmax = 2 ^ emax * Mmax = 2 ^ 15 * 1.9990234375 = 65504. However, in the standard, the maximum number is considered to be the number Fmax = 2 ^ emax = 2 ^ 15 = 32768. Numbers> 32768 are considered equal plus infinity.

    With an unbiased exponent, the maximum positive decimal number that can be written in SDFF will be equal to Fmax

    = 10 ^ emax * Mmax = 999 * 10 ^ 15 = 9.99 * 10 ^ 17


    10 . With an unbiased exponent, the minimum normalized positive decimal number in the IEEE754 format will be Fmin = 1.0 * 2 ^ -15 =
    3.0517578125 * 10 ^ -5.

    With an unbiased exponent, the minimum normalized positive decimal number that can be written in the SDF format will be Fmin = 100 * 10 ^ -15 = 10 ^ -13

    11. With an unbiased exponent, the minimum increment of the binary equivalent of a decimal number in IEEE is:

    h = 0.0000000001 * 2 ^ -15 = 2 ^ -25 = 3.0517578125 * 10 ^ -5

    With the unbiased exponent, the minimum step in SDPF coincides with the minimum number and is :

    h = 001100100 * 10 ^ -15 = 10 ^ -13


    12 . In IEEE754, the dependence function of the value of the decimal equivalent of the number Fd on its binary value is not uniform, since To change the number of the decimal mantissa by 1, a number usually requires a sum of several h, equal to the machine Ɛ.
    For example, if e = 0, for Fd1 = 1.0 = 1.0000000000 and Fd2 = 1.1≈1.0001100110 we will have
    Fd2- Fd1 = 1.0001100110 -1.000000000000 = 0.0001100110 = 0.099609375
    0.0001100110 / h = 0.0001100110 / 0.0000000001 = 1100110 = 102 = Ɛ

    In SDF, the function of dependence of the value of the decimal equivalent of the number Fd on its binary value is uniform. Any change by h of the binary equivalent of the mantissa of the decimal number entails a change of 1 least significant digit of the decimal equivalent of the number. Here the machine Ɛ = 1. Really.

    If e = 0,
    Fd1 = 100 = 0001100100
    Fd2 = 200 = 0011001000
    Fd2- Fd1 = 0011001000-0001100100 = 0001100100 = 100 = h


    In conclusion, we present the main characteristics of the representation of real numbers in the IEEE754 standard and the SDF for the exchange format consisting of 32 bits ( single-precision in IEEE754 standard).

    For IEEE754, single-precision machine word bits are distributed as S - 1 digit of the sign code, e - 8 bits of the shifted exponent, m - 23 explicit digits of the mantissa. Unpacked, m = 24.

    For IEEE754:
    The exponential bias coefficient is 127 еmax = 127. The unbiased order of the smallest normalized number with M = 1.0 is p = e-127 + 1 = -126. The numbers <2 ^ -126 are considered subnormal.

    The minimum normalized number is Fmin = 1.0 * 2 ^ -126 = 1.1754943508222875079687365372222e-38. The

    maximum normalized number
    Fmax = 2 ^ 127 = 1.7014118346046923173168730371588e + 38

    Numbers that exceed 2 ^ 127 are considered positive infinity.

    For SDDFThe machine word bits are distributed as follows: S - 1 bit, e - 7 bits, m - 24 bits. The exponential bias coefficient is 63. Then

    emax = 64
    Mmax = 9999999 Fmax
    = 9999999 * 10 ^ 64 = 9.999999 * 10 ^ 70
    Fmin = 1000000 * 10 ^ -63 = 10 ^ -57 The

    accuracy of the representation of real decimal numbers is 7 significant decimal digits.

    Also popular now: