Hubbry Logo
Quadruple-precision floating-point formatQuadruple-precision floating-point formatMain
Open search
Quadruple-precision floating-point format
Community hub
Quadruple-precision floating-point format
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Quadruple-precision floating-point format
Quadruple-precision floating-point format
from Wikipedia

In computing, quadruple precision (or quad precision) is a binary floating-point–based computer number format that occupies 16 bytes (128 bits) with precision at least twice the 53-bit double precision.

This 128-bit quadruple precision is designed for applications needing results in higher than double precision,[1] and as a primary function, to allow computing double precision results more reliably and accurately by minimising overflow and round-off errors in intermediate calculations and scratch variables. William Kahan, primary architect of the original IEEE 754 floating-point standard noted, "For now the 10-byte Extended format is a tolerable compromise between the value of extra-precise arithmetic and the price of implementing it to run fast; very soon two more bytes of precision will become tolerable, and ultimately a 16-byte format ... That kind of gradual evolution towards wider precision was already in view when IEEE Standard 754 for Floating-Point Arithmetic was framed."[2]

In IEEE 754-2008 the 128-bit base-2 format is officially referred to as binary128.

IEEE 754 quadruple-precision binary floating-point format: binary128

[edit]

The IEEE 754 standard specifies a binary128 as having:

The sign bit determines the sign of the number (including when this number is zero, which is signed). "1" stands for negative.

This gives from 33 to 36 significant decimal digits precision. If a decimal string with at most 33 significant digits is converted to the IEEE 754 quadruple-precision format, giving a normal number, and then converted back to a decimal string with the same number of digits, the final result should match the original string. If an IEEE 754 quadruple-precision number is converted to a decimal string with at least 36 significant digits, and then converted back to quadruple-precision representation, the final result must match the original number.[3]

The format is written with an implicit lead bit with value 1 unless the exponent is stored with all zeros (used to encode subnormal numbers and zeros). Thus only 112 bits of the significand appear in the memory format, but the total precision is 113 bits (approximately 34 decimal digits: log10(2113) ≈ 34.016) for normal values; subnormals have gracefully degrading precision down to 1 bit for the smallest non-zero value. The bits are laid out as:

A sign bit, a 15-bit exponent, and a 112-bit significand

Exponent encoding

[edit]

The quadruple-precision binary floating-point exponent is encoded using an offset binary representation, with the zero offset being 16383; this is also known as exponent bias in the IEEE 754 standard.

  • Emin = 000116 − 3FFF16 = −16382
  • Emax = 7FFE16 − 3FFF16 = 16383
  • Exponent bias = 3FFF16 = 16383

Thus, as defined by the offset binary representation, in order to get the true exponent, the offset of 16383 has to be subtracted from the stored exponent.

The stored exponents 000016 and 7FFF16 are interpreted specially.

Exponent Significand zero Significand non-zero Equation
000016 0, −0 subnormal numbers (−1)signbit × 2−16382 × 0.significandbits2
000116, ..., 7FFE16 normalized value (−1)signbit × 2exponentbits2 − 16383 × 1.significandbits2
7FFF16 ± NaN (quiet, signaling)

The minimum strictly positive (subnormal) value is 2−16494 ≈ 10−4965 and has a precision of only one bit. The minimum positive normal value is 2−163823.3621 × 10−4932 and has a precision of 113 bits, i.e. ±2−16494 as well. The maximum representable value is 216384 − 2162711.1897 × 104932.

Quadruple precision examples

[edit]

These examples are given in bit representation, in hexadecimal, of the floating-point value. This includes the sign, (biased) exponent, and significand.

0000 0000 0000 0000 0000 0000 0000 000116 = 2−16382 × 2−112 = 2−16494
                                          ≈ 6.4751751194380251109244389582276465525 × 10−4966
                                          (smallest positive subnormal number)

0000 ffff ffff ffff ffff ffff ffff ffff16 = 2−16382 × (1 − 2−112)
                                          ≈ 3.3621031431120935062626778173217519551 × 10−4932
                                          (largest subnormal number)

0001 0000 0000 0000 0000 0000 0000 000016 = 2−16382
                                          ≈ 3.3621031431120935062626778173217526026 × 10−4932
                                          (smallest positive normal number)

7ffe ffff ffff ffff ffff ffff ffff ffff16 = 216383 × (2 − 2−112)
                                          ≈ 1.1897314953572317650857593266280070162 × 104932
                                          (largest normal number)

3ffe ffff ffff ffff ffff ffff ffff ffff16 = 1 − 2−113
                                          ≈ 0.9999999999999999999999999999999999037
                                          (largest number less than one)

3fff 0000 0000 0000 0000 0000 0000 000016 = 1 (one)

3fff 0000 0000 0000 0000 0000 0000 000116 = 1 + 2−112
                                          ≈ 1.0000000000000000000000000000000001926
                                          (smallest number larger than one)

4000 0000 0000 0000 0000 0000 0000 000016 = 2
c000 0000 0000 0000 0000 0000 0000 000016 = −2

0000 0000 0000 0000 0000 0000 0000 000016 = 0
8000 0000 0000 0000 0000 0000 0000 000016 = −0

7fff 0000 0000 0000 0000 0000 0000 000016 = infinity
ffff 0000 0000 0000 0000 0000 0000 000016 = −infinity

3ffd 5555 5555 5555 5555 5555 5555 555516 ≈ 0.3333333333333333333333333333333333173
                                          (closest approximation to 1/3)

4000 921f b544 42d1 8469 898c c517 01b816 ≈ 3.1415926535897932384626433832795027975
                                          (closest approximation to π)

4008 74d9 9564 5aa0 0c11 d0cc 9770 5e5b16 ≈ 745.69987158227021999999999999999997147
                                          (closest approximation to the number of
                                          Watts corresponding to 1 horsepower)

By default, 1/3 rounds down like double precision, because of the odd number of bits in the significand. Thus, the bits beyond the rounding point are 0101... which is less than 1/2 of a unit in the last place.

Double-double arithmetic

[edit]

A common software technique to implement nearly quadruple precision using pairs of double-precision values is sometimes called double-double arithmetic.[4][5][6] Using pairs of IEEE double-precision values with 53-bit significands, double-double arithmetic provides operations on numbers with significands of at least[4] 2 × 53 = 106 bits (actually 107 bits[7] except for some of the largest values, due to the limited exponent range), only slightly less precise than the 113-bit significand of IEEE binary128 quadruple precision. The range of a double-double remains essentially the same as the double-precision format because the exponent has still 11 bits,[4] significantly lower than the 15-bit exponent of IEEE quadruple precision (a range of 1.8 × 10308 for double-double versus 1.2 × 104932 for binary128).

In particular, a double-double/quadruple-precision value q in the double-double technique is represented implicitly as a sum q = x + y of two double-precision values x and y, each of which supplies half of q's significand.[5] That is, the pair (x, y) is stored in place of q, and operations on q values (+, −, ×, ...) are transformed into equivalent (but more complicated) operations on the x and y values. Thus, arithmetic in this technique reduces to a sequence of double-precision operations; since double-precision arithmetic is commonly implemented in hardware, double-double arithmetic is typically substantially faster than more general arbitrary-precision arithmetic techniques.[4][5]

Note that double-double arithmetic has the following special characteristics:[8]

  • As the magnitude of the value decreases, the amount of extra precision also decreases. Therefore, the smallest number in the normalized range is narrower than double precision. The smallest number with full precision is 1000...02 (106 zeros) × 2−1074, or 1.000...02 (106 zeros) × 2−968. Numbers whose magnitude is smaller than 2−1021 will not have additional precision compared with double precision.
  • The actual number of bits of precision can vary. In general, the magnitude of the low-order part of the number is no greater than a half ULP of the high-order part. If the low-order part is less than half ULP of the high-order part, significant bits (either all 0s or all 1s) are implied between the significand of the high-order and low-order numbers. Certain algorithms that rely on having a fixed number of bits in the significand can fail when using 128-bit long double numbers.
  • Because of the reason above, it is possible to represent values like 1 + 2−1074, which is the smallest representable number greater than 1.

In addition to the double-double arithmetic, it is also possible to generate triple-double or quad-double arithmetic if higher precision is required without any higher precision floating-point library. They are represented as a sum of three (or four) double-precision values respectively. They can represent operations with at least 159/161 and 212/215 bits respectively. A natural extension to an arbitrary number of terms (though limited by the exponent range) is called floating-point expansions.

A similar technique can be used to produce a double-quad arithmetic, which is represented as a sum of two quadruple-precision values. They can represent operations with at least 226 (or 227) bits.[9]

Implementations

[edit]

Quadruple precision is often implemented in software by a variety of techniques (such as the double-double technique above, although that technique does not implement IEEE quadruple precision), since direct hardware support for quadruple precision is, as of 2016, less common (see "Hardware support" below). One can use general arbitrary-precision arithmetic libraries to obtain quadruple (or higher) precision, but specialized quadruple-precision implementations may achieve higher performance.

Computer-language support

[edit]

A separate question is the extent to which quadruple-precision types are directly incorporated into computer programming languages.

Quadruple precision is specified in Fortran by the real(real128) (module iso_fortran_env from Fortran 2008 must be used, the constant real128 is equal to 16 on most processors), or as real(selected_real_kind(33, 4931)), or in a non-standard way as REAL*16. (Quadruple-precision REAL*16 is supported by the Intel Fortran Compiler[10] and by the GNU Fortran compiler[11] on x86, x86-64, and Itanium architectures, for example.)

For the C programming language, ISO/IEC TS 18661-3 (floating-point extensions for C, interchange and extended types) specifies _Float128 as the type implementing the IEEE 754 quadruple-precision format (binary128).[12] Alternatively, in C/C++ with a few systems and compilers, quadruple precision may be specified by the long double type, but this is not required by the language (which only requires long double to be at least as precise as double), nor is it common.

As of C++23, the C++ language defines a <stdfloat> header that contains fixed-width floating-point types. Implementations of these are optional, but if supported, std::float128_t corresponds to quadruple precision.

On x86 and x86-64, the most common C/C++ compilers implement long double as either 80-bit extended precision (e.g. the GNU C Compiler gcc[13] and the Intel C++ Compiler with a /Qlong‑double switch[14]) or simply as being synonymous with double precision (e.g. Microsoft Visual C++[15]), rather than as quadruple precision. The procedure call standard for the ARM 64-bit architecture (AArch64) specifies that long double corresponds to the IEEE 754 quadruple-precision format.[16] On a few other architectures, some C/C++ compilers implement long double as quadruple precision, e.g. gcc on PowerPC (as double-double[17][18][19]) and SPARC,[20] or the Sun Studio compilers on SPARC.[21] Even if long double is not quadruple precision, however, some C/C++ compilers provide a nonstandard quadruple-precision type as an extension. For example, gcc provides a quadruple-precision type called __float128 for x86, x86-64 and Itanium CPUs,[22] and on PowerPC as IEEE 128-bit floating-point using the -mfloat128-hardware or -mfloat128 options;[23] and some versions of Intel's C/C++ compiler for x86 and x86-64 supply a nonstandard quadruple-precision type called _Quad.[24]

Zig provides support for it with its f128 type.[25]

Google's work-in-progress language Carbon provides support for it with the type called f128.[26]

As of 2024, Rust is currently working on adding a new f128 type for IEEE quadruple-precision 128-bit floats.[27]

Libraries and toolboxes

[edit]
  • The GCC quad-precision math library, libquadmath, provides __float128 and __complex128 operations.
  • The Boost multiprecision library Boost.Multiprecision provides unified cross-platform C++ interface for __float128 and _Quad types, and includes a custom implementation of the standard math library.[28]
  • The Multiprecision Computing Toolbox for MATLAB allows quadruple-precision computations in MATLAB. It includes basic arithmetic functionality as well as numerical methods, dense and sparse linear algebra.[29]
  • The DoubleFloats[30] package provides support for double-double computations for the Julia programming language.
  • The doubledouble.py[31] library enables double-double computations in Python. [citation needed]
  • Mathematica supports IEEE quad-precision numbers: 128-bit floating-point values (Real128), and 256-bit complex values (Complex256).[citation needed]

Hardware support

[edit]

IEEE quadruple precision was added to the IBM System/390 G5 in 1998,[32] and is supported in hardware in subsequent z/Architecture processors.[33][34] The IBM POWER9 CPU (Power ISA 3.0) has native 128-bit hardware support.[23]

Native support of IEEE 128-bit floats is defined in PA-RISC 1.0,[35] and in SPARC V8[36] and V9[37] architectures (e.g. there are 16 quad-precision registers %q0, %q4, ...), but no SPARC CPU implements quad-precision operations in hardware as of 2004.[38]

Non-IEEE extended-precision (128 bits of storage, 1 sign bit, 7 exponent bits, 112 fraction bits, 8 bits unused) was added to the IBM System/370 series (1970s–1980s) and was available on some System/360 models in the 1960s (System/360-85,[39] -195, and others by special request or simulated by OS software).

The Siemens 7.700 and 7.500 series mainframes and their successors support the same floating-point formats and instructions as the IBM System/360 and System/370.

The VAX processor implemented non-IEEE quadruple-precision floating point as its "H Floating-point" format. It had one sign bit, a 15-bit exponent and 112-fraction bits, however the layout in memory was significantly different from IEEE quadruple precision and the exponent bias also differed. Only a few of the earliest VAX processors implemented H Floating-point instructions in hardware, all the others emulated H Floating-point in software.

The NEC Vector Engine architecture supports adding, subtracting, multiplying and comparing 128-bit binary IEEE 754 quadruple-precision numbers.[40] Two neighboring 64-bit registers are used. Quadruple-precision arithmetic is not supported in the vector register.[41]

The RISC-V architecture specifies a "Q" (quad-precision) extension for 128-bit binary IEEE 754-2008 floating-point arithmetic.[42] The "L" extension (not yet certified) will specify 64-bit and 128-bit decimal floating point.[43]

Quadruple-precision (128-bit) hardware implementation should not be confused with "128-bit FPUs" that implement SIMD instructions, such as Streaming SIMD Extensions or AltiVec, which refers to 128-bit vectors of four 32-bit single-precision or two 64-bit double-precision values that are operated on simultaneously.

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The quadruple-precision floating-point format, officially designated as binary128 in the standard, is a 128-bit binary interchange format designed for representing real numbers with significantly higher precision and a vastly expanded compared to double-precision formats. It consists of a 1-bit sign field, a 15-bit exponent field with a bias of 16383, and a 112-bit trailing field, which together provide an effective precision of 113 bits when including the implicit leading bit for normalized numbers. This structure allows for approximately 34 decimal digits of precision, enabling accurate computations in fields such as scientific simulations and where double precision's limitations become apparent. The format supports a wide exponent range, with the minimum exponent (emin) of -16382 and maximum exponent (emax) of 16383, corresponding to normalized values roughly from 3.362 × 10^{-4932} to 1.189 × 10^{4932}, far exceeding the capabilities of 64-bit double precision. Special values such as subnormals, infinities, and are encoded using reserved exponent patterns, with exponent all zeros indicating subnormals or zero, and all ones denoting infinities or NaNs distinguished by the significand bits. Binary128 was formally introduced in the 2008 revision of the standard to address demands for in computational applications, building on the original 1985 standard's single- and double-precision formats. While hardware support remains limited—primarily in IBM Power processors such as and —software implementations are widespread, including the __float128 type in GCC compilers and libraries such as MPFR for . Its use is particularly valuable in for tasks requiring minimal rounding errors over extended calculations, though the increased storage and computational overhead make it unsuitable for general-purpose applications.

Overview

Definition and Standards

Quadruple-precision floating-point format, also known as binary128, is a binary floating-point representation that utilizes 128 bits to encode numerical values with high accuracy, providing approximately 34 digits of precision. This format builds on the fundamental structure of floating-point numbers, which consist of a to indicate positive or negative values, an exponent to scale the magnitude, and a (also called mantissa) to represent the of the number. The standard specified single (binary32) and double (binary64) precisions, along with an optional format without a rigidly specified bit layout. It was not until the that quadruple precision was formally defined as the binary128 interchange format, establishing precise encoding rules to ensure portability and consistency across computing systems. This revision defined binary128 as a standardized format suitable for applications requiring greater numerical fidelity than double precision's roughly 15-16 decimal digits. In the IEEE 754-2008 standard, binary128 serves as both an arithmetic format and an interchange format, mandating exact representation for data exchange between implementations to prevent loss of precision during transfers. The subsequent IEEE 754-2019 revision retained this definition with minor clarifications, reinforcing binary128's role in supporting high-precision computations while emphasizing compatibility with prior formats. These standards collectively ensure that quadruple precision adheres to uniform rules for operations, , and , promoting reliability in scientific and engineering applications.

Precision and Range Characteristics

The quadruple-precision floating-point format, as defined in IEEE 754-2008 under the binary128 interchange format, provides a of 113 bits, consisting of 112 explicitly stored bits and 1 implicit leading bit for normalized numbers. This configuration delivers approximately 34 digits of precision, enabling highly accurate representations in computations where double-precision (about 15-16 digits) is insufficient. The is determined by a 15-bit exponent field with a of 16383, allowing unbiased exponents from -16382 to +16383 for normalized finite values. Consequently, the smallest positive normalized value is approximately 3.4 × 10^{-4932}, while the largest is approximately 1.2 × 10^{4932}. The numerical value of a finite non-zero binary128 number is given by the formula: (1)s×(1+m2112)×2e16383(-1)^s \times \left(1 + \frac{m}{2^{112}}\right) \times 2^{e - 16383} where ss is the sign bit (0 or 1), mm is the 112-bit mantissa (fraction), and ee is the biased exponent (an integer from 1 to 32766). Relative precision is characterized by the machine epsilon, which is 21121.93×10342^{-112} \approx 1.93 \times 10^{-34}, representing the spacing between representable numbers around 1.0 and the maximum relative error bound in rounding operations. Additions to 1.0 below this threshold may not be distinguishable in the format. Such precision supports applications in scientific simulations demanding extreme accuracy, though hardware support remains limited.

Applications and Use Cases

Quadruple-precision floating-point format finds primary application in high-precision scientific domains where double-precision arithmetic (approximately 15-16 digits) proves insufficient for maintaining accuracy over extended computations. In , it enables precise solutions to the Kepler equation and long-term orbit integrations by minimizing accumulation of rounding errors in iterative solvers. For instance, specialized algorithms for hyperbolic Kepler equation solutions achieve superior precision in quadruple mode compared to double, supporting accurate trajectory predictions in space mission planning. Similarly, in computations, quadruple precision facilitates reliable evaluation of complex integrals and eigenvalue problems, where small numerical instabilities can propagate significantly in methods like coupled-cluster theory. tasks, such as solving stiff differential equations via high-order Runge-Kutta-Nyström integrators, also benefit from its extended range and precision, allowing stable simulations of quantum mechanical systems with up to 34 digits of accuracy. The format's advantages stem from its capacity to reduce rounding errors in iterative algorithms, thereby enabling longer stable computations without precision loss. In orbital , hybrid-precision approaches combining double and quadruple arithmetic for increment calculations preserve dynamical over millennia-scale integrations, outperforming pure double-precision methods in symplectic solvers for N-body problems. This error mitigation is particularly valuable in applications requiring verifiable high accuracy, such as recognizing numerical constants or discovering mathematical identities through extended arithmetic. Despite these benefits, quadruple precision introduces challenges, including substantially increased computational cost and usage, often necessitating trade-offs in large-scale simulations. Software implementations typically run 5 to 10 times slower than double precision due to the complexity of 128-bit operations, while demands double compared to 64-bit formats, impacting in memory-bound workloads. In climate modeling, where global simulations involve vast grids and iterative atmospheric dynamics, the heightened precision helps mitigate instabilities in sensitive parametrizations but at the expense of prolonged run times, prompting hybrid strategies to balance accuracy and efficiency. simulations similarly employ it for high-accuracy integrators in event generators, though the overhead limits routine use to critical subroutines, as seen in precision-sensitive methods. Specific projects illustrate these applications: In , software frameworks supporting , like those integrating quadruple arithmetic for correlated methods, enable benchmark calculations that validate theoretical models against experimental data. As of 2024, libraries like have introduced native support for quadruple precision, facilitating its use in Python-based scientific workflows.

IEEE 754 Binary128 Format

Bit Layout and Components

The binary128 format, as specified in the IEEE 754 standard, allocates its 128 bits into three primary fields: a 1-bit sign field, a 15-bit exponent field, and a 112-bit mantissa field (also referred to as the significand or fraction). This structure enables representation of a wide range of real numbers with high precision, where the total bit width balances sign determination, scaling, and fractional detail. The sign bit, occupying the most significant position, determines the polarity of the represented value: 0 denotes a non-negative number, while 1 indicates a negative number. The exponent field provides the scaling factor for the number's magnitude, allowing adjustment of the position of the binary point. The mantissa field stores the fractional digits, capturing the significant bits that define the number's precision beyond the scaling. Visually, the bit layout is structured as:

| Sign (1 bit) | Exponent (15 bits) | Mantissa (112 bits) |

| Sign (1 bit) | Exponent (15 bits) | Mantissa (112 bits) |

This linear arrangement facilitates efficient packing and processing in memory and hardware. For normalized representations, the mantissa employs an implicit leading bit of 1, which is not explicitly stored in the 112 bits; this "hidden bit" mechanism extends the effective precision to 113 bits by assuming the significand is in the range [1, 2). The normalization process ensures that non-zero numbers are adjusted to this form, aligning the leading 1 to the highest possible bit position for optimal precision utilization.

Exponent Encoding and Bias

In the IEEE 754 binary128 quadruple-precision format, the exponent is represented by a 15-bit field, allowing for 2^{15} = 32,768 possible encoded values ranging from 0 to 32,767. The all-zero encoding (0) and all-one encoding (32,767) are reserved for special values, leaving the range 1 through 32,766 for finite numbers. This design follows the general convention for binary floating-point formats, where the exponent field width determines the bias as 2^{14} - 1 = 16,383 to enable symmetric representation around zero. For normal numbers, the actual exponent e is obtained by subtracting the from the encoded exponent value E, yielding e = E - 16,383, where E ranges from 1 to 32,766. This ing shifts the exponent range to positive encoded values, facilitating unsigned binary storage while supporting both positive and negative powers of two from e = -16,382 to e = 16,383. The ensures that the smallest normal exponent aligns efficiently with the format's precision requirements. Denormalized numbers, also known as subnormals, are encoded with E = 0 and a non-zero trailing , representing the smallest magnitudes without underflow to zero. In this case, the effective exponent is fixed at e = -16,382 (equivalently, 1 - 16,383), and the is interpreted with an explicit bit rather than the implicit one used for normals, allowing gradual underflow. This mechanism preserves relative precision near zero by scaling the appropriately with the exponent. Overflow and underflow conditions are handled through the reserved encodings: E = 32,767 (all ones) with a zero denotes (±∞ depending on the ), while the same encoding with a non-zero indicates a (not-a-number). Conversely, E = 0 with a zero represents zero (±0), distinguishing signed zeros for certain computations. These conventions ensure consistent handling of exceptional cases across formats.

Mantissa Representation and Normalization

In the IEEE 754 binary128 quadruple-precision format, the mantissa, also known as the , is represented by a 112-bit field stored explicitly in the bit layout. For normalized numbers, an implicit leading bit of 1 is assumed before the , resulting in a total precision of 113 bits. This structure allows for high-fidelity representation of the , where the value of the is 1.f×2E163831.f \times 2^{E - 16383}, with ff denoting the 112-bit and EE the biased exponent (bias = 16383). Normalization in binary128 ensures that the significand is always in the range [1,2)[1, 2) for finite nonzero normal numbers by hiding the leading 1 bit, which optimizes storage and maintains consistent precision across the exponent range. The normalization process involves left-shifting the mantissa until the leading bit is 1, adjusting the exponent accordingly to preserve the value. This implicit bit convention, inherited from earlier IEEE 754 formats, maximizes the effective precision without dedicating a bit to the leading 1. Denormalized (subnormal) numbers occur when the exponent field is all zeros (biased exponent E=0E = 0) and the is nonzero, in which case the implicit leading bit is taken as 0 rather than 1. This design enables gradual underflow, allowing representation of values smaller than the smallest (2163822^{-16382}) down to approximately 2164942^{-16494}, but at the cost of reduced precision. The effective number of significant bits decreases progressively as more leading zeros appear in the ; for instance, near zero, the precision can drop to as few as 1 bit when only the least significant bit of the is set. IEEE 754 mandates support for five modes in arithmetic operations involving binary128 numbers, with to nearest, ties to even as the default mode to minimize and ensure reproducibility. In this mode, results are rounded to the nearest representable value, and ties (exactly halfway between two representable values) are resolved by to the even (least significant bit 0) mantissa. Other modes include directed (toward positive or negative , or toward zero) and ties away from zero, which may be selected for specific computational needs but can introduce directional if used pervasively. These modes apply uniformly to the 113-bit during normalization and post-operation adjustments.

Special Values and Edge Cases

In the IEEE 754 binary128 format, is represented by setting the exponent field to all zeros and the field to all zeros, with the specifying either positive (sign bit 0, all other bits 0) or negative (sign bit 1). These representations allow for signed zeros, which are treated as equivalent in most arithmetic operations and comparisons, such as or equality checks, to preserve mathematical consistency, though they may differ in specific contexts like reciprocals (1 / +0 yields +∞, while 1 / -0 yields -∞). Infinite values are encoded with the 15-bit exponent field set to all ones (binary 111111111111111, or 32767 in decimal) and the 112-bit significand field set to zero, where the sign bit determines positive or negative . This encoding is used to represent the result of overflow conditions, such as when the magnitude of a computation exceeds the maximum representable finite value (approximately 1.18973149535723176502 × 10^{4932}), depending on the rounding mode and . Not-a-Number (NaN) values are indicated by an exponent field of all ones and a non-zero field, allowing a vast payload for diagnostic information (up to 111 bits after the leading bit). Within this, quiet NaNs have the most significant bit of the set to 1, propagating through operations without signaling an invalid-operation exception, while signaling NaNs have this bit set to 0 and are intended to trigger such exceptions upon use in arithmetic. Subnormal numbers, an edge case for gradual underflow, are represented with an exponent field of zero and a non-zero significand, effectively using the minimum exponent (–16382) without an implicit leading 1, filling the gap between zero and the smallest normalized number (approximately 3.36210314311209350626 × 10^{-4932}). This mechanism ensures smoother transitions near underflow thresholds compared to abrupt flushing to zero.

Alternative High-Precision Methods

Double-Double Arithmetic

Double-double arithmetic is a software-emulated technique for achieving higher precision by representing numbers as the unevaluated sum of two binary64 (double-precision) floating-point values, denoted as x=a+bx = a + b, where aa is the high part and bb is the low part with ba/253|b| \leq |a| / 2^{53} to ensure non-overlapping s and maintain a . This pairing effectively extends the to approximately 106 bits, providing about 32 decimal digits of precision, which approximates the capabilities of quadruple-precision formats like binary128 without requiring native hardware support. The representation allows for portable implementation across systems lacking 128-bit floating-point units, with steps applied after operations to preserve the bound on the low part. Key operations in double-double arithmetic rely on error-free transformations to avoid precision loss. Addition of two double-double numbers (a1,b1)+(a2,b2)(a_1, b_1) + (a_2, b_2) begins by summing the high parts and low parts separately using floating-point addition, followed by an error-free summation algorithm such as TWO-SUM or FAST-TWO-SUM to combine the results exactly. The TWO-SUM algorithm, for inputs pp and qq, computes s=pqs = p \oplus q, then derives the roundoff error ee such that p+q=s+ep + q = s + e exactly, ensuring non-overlapping components; FAST-TWO-SUM is a variant assuming pq|p| \geq |q| for efficiency, using s=pqs = p \oplus q, δ=q(sp)\delta = q - (s \ominus p), yielding the pair (s,δ)(s, \delta). These steps, applied iteratively, bound the in the sum by 21062^{-106} times the result magnitude, with subsequent to . Multiplication employs a similar , computing the product (a1,b1)×(a2,b2)(a_1, b_1) \times (a_2, b_2) via the expansion (a1+b1)(a2+b2)=a1a2+(a1b2+a2b1)+b1b2(a_1 + b_1)(a_2 + b_2) = a_1 a_2 + (a_1 b_2 + a_2 b_1) + b_1 b_2, where each cross-term product uses a analogous to TWO-SUM for exact . This approach resembles a two-term Karatsuba , reducing the number of full-precision multiplications while capturing errors, resulting in an error bound of approximately 21062^{-106} for the overall operation. Conversion to and from single double-precision involves the combined value, preserving the effective unit of 2106\approx 2^{-106}. Compared to native quadruple-precision implementations, double-double arithmetic offers portability on hardware without 128-bit support, enabling high-precision computations in standard double-precision environments with performance closer to native doubles than arbitrary-precision libraries, albeit with operations roughly 4-10 times slower due to multiple steps. This method has been foundational in libraries for scientific computing, providing rigorous error control for applications requiring extended precision.

Paired and Block Floating-Point Techniques

Paired floating-point techniques extend precision beyond standard double-precision formats by representing numbers as sums of multiple lower-precision components, often two or more, to achieve effective quadruple or higher accuracy without native hardware support. These methods, known as floating-point expansions, store a number as an unevaluated sum of non-overlapping machine-precision floats, allowing adaptive refinement of computations to control errors. For instance, a quad-precision value can be approximated using expansions of four double-precision numbers, enabling operations like and through algorithms such as EXPANSION-SUM and TWO-PRODUCT, which refine results by isolating error terms. This technique, exemplified by algorithms that maintain a compensation accumulator for roundoff residuals, improves the accuracy of sums by up to the full available, though it requires careful control of register precision to avoid unintended intermediate rounding. Double-double arithmetic represents a related approach, using two doubles to simulate higher precision, but paired methods generalize to longer expansions for broader applications. Block floating-point techniques apply a shared exponent across a block or array of fixed-point mantissas, providing in applications where individual exponents would be inefficient. This format scales the entire block dynamically based on the maximum magnitude, preserving precision within fixed-point hardware while extending the effective range to handle signals with wide amplitude variations, such as in FFT computations. For example, in DSP implementations like the TMS320C54x, block floating-point improves by 41% to 58% over pure fixed-point methods for 64-point complex FFTs, by tracking and adjusting exponents stage-by-stage to prevent overflow. analysis in such systems shows that the shared exponent introduces bounded quantization noise, but the overall gain makes it suitable for audio and . Other techniques for quadruple-like precision involve multiple accumulators, where parallel single- or double-precision units sum partial results to form higher-precision outputs, particularly in (FFT) implementations requiring robust geometric or numerical predicates. In adaptive arithmetic frameworks, these accumulators refine expansions during FFT stages, ensuring exactness in predicates like orientation tests by eliminating zero components and normalizing sums, though at a computational cost of several times the base flops. Such methods are applied in robust geometric computing, where expansions of up to 16 terms handle ill-conditioned inputs without full quad-precision hardware. These non-native approaches incur higher overhead than IEEE 754 binary128, and block formats limited to array-based domains like . They excel in specific areas such as audio processing for in filters and for precise , but their domain specificity and error management needs restrict general-purpose use.

Implementations and Support

Programming Language Integration

Several programming languages provide native support for quadruple-precision floating-point arithmetic, primarily through compiler extensions that implement the binary128 format. In , the REAL(KIND=16) type specifier declares 128-bit floating-point variables, enabling high-precision computations with full support for arithmetic operations, including addition, multiplication, and division, as well as intrinsic functions like SQRT and EXP. This feature has been available in major Fortran compilers such as gfortran and Fortran since the Fortran 95 standard, which introduced selected real kinds for . For input/output, Fortran's standard formatted I/O handles REAL(KIND=16) values, though precision control may require explicit format specifiers to avoid truncation. In C and C++, the GNU Compiler Collection (GCC) and provide native support via the non-standard __float128 type, introduced in GCC version 4.3 in to facilitate quadruple-precision calculations on platforms like x86, , and PowerPC. This type supports standard arithmetic operators (+, -, *, /) and comparisons, with literals denoted by suffixes like 'q' (e.g., 1.0q). requires specialized functions from the libquadmath library, such as quadmath_snprintf for formatted printing, as standard does not directly support __float128. The ISO/IEC 9899:2023 (C23) standard later formalized optional interchange types like _Float128, which aliases to __float128 in compatible compilers, promoting greater portability in future codebases. Despite this support, quadruple-precision integration remains non-standard across most languages, leading to portability challenges; for instance, code using __float128 must be compiled with specific GCC or flags, such as -mfloat128 on PowerPC targets, and may fall back to software emulation on hardware without native 128-bit instructions. Languages like and Python lack built-in quadruple-precision types, often relying on external libraries for emulation.

Software Libraries and Toolboxes

The library is a C library that implements arbitrary-precision binary with correct , allowing users to configure the mantissa precision to 128 bits for computations equivalent to quadruple precision. It supports all standard operations, including special values like infinities and NaNs, and is built on the GMP library for efficient handling of large exponents. MPFR's emulation mode ensures portability across platforms without native hardware support, with optimizations such as assembly-optimized routines for basic arithmetic on x86 architectures. The QD library provides double-double and quad-double arithmetic types, where the double-double format—representing numbers as unevaluated sums of two IEEE double-precision values—delivers at least 106 bits of significand precision, approximating the 113-bit mantissa of quadruple precision while offering about 34 decimal digits of accuracy. Implemented in ANSI C++ with full operator and function overloading, it enables seamless mixing of double, double-double, and quad-double types in expressions, supporting algebraic operations (e.g., roots and powers), transcendental functions (e.g., sine and logarithm), and input/output conversions. For performance, QD employs error-free transformations and renormalization to minimize rounding errors, making it suitable for emulation on standard hardware; it has been integrated into C++ scientific applications, such as parallel simulations in computational fluid dynamics, where high accuracy is critical for long-running calculations. Boost.Multiprecision is a C++ header-only library that includes the float128 type for direct support of the binary128 quadruple-precision format, featuring a 113-bit mantissa, 15-bit exponent, and full compliance with std::numeric_limits for properties like maximum digits (36 decimal). It offers drop-in replacement for built-in float types, with constexpr support for arithmetic and comparisons (from with GCC), and integrates with Boost.Math for special functions like gamma. Emulation is handled via backends like GCC's __float128 or Intel's _Quad, with optimizations for conversion and I/O to reduce overhead in numerical algorithms. MATLAB's Symbolic Math Toolbox incorporates variable-precision arithmetic through the vpa function, which evaluates expressions to a user-specified number of significant digits—such as 34 for quadruple-precision equivalence—using arbitrary-precision floating-point internally. This toolbox supports numeric, symbolic, vector, and matrix operations, restoring exact forms (e.g., rational or pi-based) when possible and employing guard digits to mitigate round-off, though it relies on software emulation for precisions beyond native double. In Python environments, the mpmath library delivers arbitrary-precision real and complex , configurable to 128 bits or higher (e.g., via mp.dps = 34 for quadruple-level decimal precision), and extends to through array conversions or wrappers like mpmath.matrix for vectorized high-precision computations. It includes optimized algorithms for integration, special functions, and linear algebra, with emulation based on Python's arbitrary-precision integers or optional GMP backends for speed. Post-2020 developments have enhanced GPU compatibility for these libraries, including 's addition of __float128 mathematical functions (e.g., sine, ) for device code on platforms with host compiler support, enabling quadruple-precision emulation in workflows. Extensions like GQD, a GPU-ported version of the QD library, leverage for double-double and quad-double operations on hardware, achieving up to several times the throughput of CPU baselines for basic arithmetic in scientific simulations.

Hardware and Processor Support

Native hardware support for quadruple-precision floating-point (IEEE 754 binary128) remains limited across modern processors, primarily due to the computational overhead and niche demand for such high precision in most applications. Central processing units (CPUs) generally lack full 128-bit s (FPUs), relying instead on extended formats that fall short of true quadruple precision. For instance, the x87 FPU, a legacy component in x86-64 architectures, provides 80-bit with a 64-bit mantissa, which exceeds double precision (64-bit) but does not match the 113-bit mantissa of binary128. Similarly, ARMv8-A processors feature 128-bit vector registers for SIMD operations but offer native floating-point hardware only up to 64-bit double precision; quadruple-precision computations require software libraries without dedicated . An exception is found in IBM's PowerPC , where and later processors include native hardware support for 128-bit quadruple-precision arithmetic, enabling direct execution of binary128 operations in the vector-scalar . Graphics processing units (GPUs) provide partial support through programming interfaces but rarely feature native quadruple-precision hardware. NVIDIA's platform has included quadruple-precision mathematical functions since version 3.0 (around 2010), allowing use of the __float128 type on devices, but this relies on software emulation rather than dedicated hardware pipelines, resulting in performance that is typically 1/100th or less of double-precision throughput on consumer GPUs like the Tesla C1060. AMD's platform supports quadruple precision via emulated data types in libraries like rocBLAS, but GPU hardware such as the CDNA2 architecture (e.g., MI250) natively accelerates only up to 64-bit double precision, with quad operations falling back to slower scalar processing that achieves roughly 1/4 the speed of double-precision kernels. These emulations highlight GPUs' optimization for lower-precision workloads in machine learning and graphics, where quadruple precision offers . Historically, some supercomputers provided native support for extended precisions approximating . In the , systems like the Y-MP utilized 120-bit floating-point formats for REAL*16 operations, delivering hardware-accelerated high-precision arithmetic that closely aligned with needs for scientific simulations, though not strictly compliant. Modern x86 extensions, such as , enhance vectorized double precision but omit dedicated quadruple-precision instructions, underscoring a shift away from hardware-level high precision in favor of software . For processors lacking native support, software fallbacks using arithmetic enable precision at the cost of reduced performance. Looking forward, the is incorporating quadruple-precision capabilities through its ratified "" standard extension (version 2.2), which defines 128-bit floating-point instructions dependent on the double-precision "D" extension and was integrated into the unprivileged specification by 2020. This modular extension allows implementers to add hardware support optionally, potentially appearing in future cores post-2023 for embedded and , though widespread adoption remains pending hardware realizations.

References

Add your contribution
Related Hubs
User Avatar
No comments yet.