PD ISO IEC TS 18661 — Floating-Point Extensions for C Technical Specification Series

Information Technology — Programming Languages, their Environments and System Software Interfaces — Floating-Point Extensions for C (PD ISO/IEC TS 18661)

💻 PD ISO/IEC TS 18661 is a Published Document series issued by BSI adopting the ISO/IEC technical specification TS 18661, providing floating-point extensions for the C language. C floating-point arithmetic is jointly defined by the C standard (ISO/IEC 9899) and the IEEE 754 floating-point standard; this series extends it, supporting higher-precision binary floating-point, decimal floating-point, interchange/extended types and supplementary functions, for high-performance numerical computation, financial decimal arithmetic, embedded and scientific computing. Developed by ISO/IEC JTC 1/SC 22 (Programming languages).

💡 ISO/IEC TS is a “technical specification”, a transitional document for compiler vendors and users to implement first and, once proven, to be merged into the formal C standard. This series aims to give “non-standard but widely needed floating-point features” a unified interface and behaviour definition.

1. Series Structure and Document Scope 📌

DocumentSubjectEditionStatus
PD ISO/IEC TS 18661-1Binary floating-point arithmetic2014Readable
PD ISO/IEC TS 18661-2Decimal floating-point arithmetic2015Readable
PD ISO/IEC TS 18661-3Interchange and extended types2015Readable
PD ISO/IEC TS 18661-4Supplementary functions (scanned)2015Scanned
PD ISO/IEC TS 18661-5Interchange formats (scanned)2016Scanned
⚠️ Parts 4 and 5 are scanned versions whose full text cannot be extracted; they are summarised here in line with the consistent framework of C floating-point extensions. Always refer to the BSI official published versions for specific clauses.

2. Binary Floating-Point Arithmetic (Part 1) 🧮

Part 1 introduces binary floating-point arithmetic extensions to C. The C standard (e.g., C11) already supports IEEE 754-based float/double/long double; this part extends the _FloatN type family, including _Float16, _Float32, _Float64, _Float128, etc., and specifies their representation, arithmetic, rounding and conversion rules. Its content covers:

  • Type definitions: precision, range and storage format of _FloatN types (per IEEE 754).
  • Arithmetic: add/subtract/multiply/divide, comparison, rounding, special values (infinity, NaN, ±0) behaviour.
  • Function interfaces: e.g., fmax/fmin, fma fused multiply-add.
  • Conformance: conformance requirements with the C standard (freestanding implementations, predefined macros).

This part lets C conveniently use higher-precision binary floating-point while maintaining IEEE 754-consistent portable behaviour.

💡 Higher-precision binary floating-point is significant for scientific computing and engineering simulation (e.g., CFD, finite elements): _Float128 can markedly reduce rounding-error accumulation, and this part provides standardised type and function support for such applications.

3. Decimal Floating-Point Arithmetic (Part 2) 💰

Part 2 introduces decimal floating-point arithmetic to C. Unlike binary floating-point, decimal floating-point can exactly represent decimal fractions (e.g., 0.1, 0.01), avoiding the rounding error from binary’s inability to exactly represent most decimal fractions — essential for financial, accounting and monetary calculations. Its content includes:

  • Decimal floating-point types: _Decimal32, _Decimal64, _Decimal128.
  • Representation and arithmetic: decimal encoding (e.g., IEEE 754 DPD/BID), rounding rules, operation semantics.
  • Function interfaces: decimal-specific mathematical functions and conversions.
  • Conformance: conformance requirements with the C standard (including freestanding implementations and predefined macros).
⚠️ Decimal floating-point is “finance-friendly” but “more complex to implement”: it exactly represents decimal fractions, but implementation needs software emulation or dedicated hardware. Part 2 defines uniform behaviour so decimal arithmetic results are predictable across platforms.

4. Interchange and Extended Types (Part 3) 🔗

Part 3 specifies interchange formats and extended types. Interchange formats are floating-point representations with fixed byte order and width for data exchange, ensuring interchangeability of floating-point data across platforms/compilers; extended types are higher precision/range extensions beyond basic types. Content covers definition of interchange formats, storage layout, alignment and type conversion, providing standardised floating-point encoding for cross-platform data transfer and storage (files, networks, databases).

5. Supplementary Functions and Interchange Format Details (Parts 4/5) 🧩

Part 4 specifies supplementary functions, such as floating-point extended versions of logarithms, exponentials, trigonometric and inverse functions, and special functions (e.g., gamma, error functions), providing standardised interfaces for scientific computing. Part 5 further details the specific bit layout, encoding and decoding rules of interchange formats, supplementing Part 3 to ensure determinism of cross-platform floating-point data exchange.

6. Engineering Practice Application 🛠️

  • 🔍 Numerical computing: for high-precision scientific computing, use extended types such as _Float128 to reduce rounding error.
  • 🔧 Financial computing: for currency and accounting operations, use decimal floating-point _DecimalN for exact decimal-fraction arithmetic.
  • 📊 Cross-platform data exchange: encode floating-point data per the Part 3/5 interchange formats for exchangeability across platforms/compilers.
  • 📋 Compiler support: confirm the compiler implements TS 18661 (e.g., GCC/Clang _FloatN), and enable relevant feature macros when needed.

7. Frequently Asked Questions ❓

❓ Q: How does PD ISO/IEC TS 18661 relate to IEEE 754?
A: It builds on the IEEE 754 floating-point standard, bringing IEEE 754 binary/decimal floating-point formats and arithmetic into C, and extending higher-precision types and supplementary functions.
❓ Q: What is the difference between binary and decimal floating-point?
A: Binary floating-point cannot exactly represent most decimal fractions (e.g., 0.1); decimal floating-point can. The latter suits financial computing, the former general scientific computing.
❓ Q: What is _Float128 used for?
A: It provides about 34 decimal digits of precision for high-precision scientific computing, markedly reducing rounding-error accumulation, especially for large simulations such as CFD and finite elements.
❓ Q: What does the interchange format solve?
A: It defines floating-point encoding with fixed byte order and width, ensuring interchangeability of floating-point data across platforms/compilers and avoiding interpretation ambiguity in cross-platform data transfer.
❓ Q: Do mainstream compilers support it now?
A: GCC/Clang already support some _FloatN and decimal floating-point extensions; the exact support level must be checked in compiler documentation, enabling feature macros when needed.
🔒
正在加载下载地址,请稍候 10 秒

Leave a Reply

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