ISO/IEC TS 18661-2:2015
(Main)Information Technology - Programming languages, their environments, and system software interfaces - Floating-point extensions for C - Part 2: Decimal floating-point arithmetic
Information Technology - Programming languages, their environments, and system software interfaces - Floating-point extensions for C - Part 2: Decimal floating-point arithmetic
ISO/IEC/TS 18661-2:2015 extends programming language C as specified in ISO/IEC 9899:2011, (C11) with changes specified in ISO/IEC/TS 18661-1, to support decimal floating-point arithmetic conforming to ISO/IEC/IEEE 60559:2011. It covers all requirements of IEC 60559 as they pertain to C decimal floating types. ISO/IEC/TS 18661-2:2015 does not cover binary floating-point arithmetic (which is covered in ISO/IEC/TS 18661-1), nor does it cover most optional features of IEC 60559.
Technologies de l'information — Langages de programmation, leurs environnements et interfaces du logiciel système — Extensions à virgule flottante pour C — Partie 2: Arithmétique décimal en virgule flottante
General Information
Relations
Frequently Asked Questions
ISO/IEC TS 18661-2:2015 is a technical specification published by the International Organization for Standardization (ISO). Its full title is "Information Technology - Programming languages, their environments, and system software interfaces - Floating-point extensions for C - Part 2: Decimal floating-point arithmetic". This standard covers: ISO/IEC/TS 18661-2:2015 extends programming language C as specified in ISO/IEC 9899:2011, (C11) with changes specified in ISO/IEC/TS 18661-1, to support decimal floating-point arithmetic conforming to ISO/IEC/IEEE 60559:2011. It covers all requirements of IEC 60559 as they pertain to C decimal floating types. ISO/IEC/TS 18661-2:2015 does not cover binary floating-point arithmetic (which is covered in ISO/IEC/TS 18661-1), nor does it cover most optional features of IEC 60559.
ISO/IEC/TS 18661-2:2015 extends programming language C as specified in ISO/IEC 9899:2011, (C11) with changes specified in ISO/IEC/TS 18661-1, to support decimal floating-point arithmetic conforming to ISO/IEC/IEEE 60559:2011. It covers all requirements of IEC 60559 as they pertain to C decimal floating types. ISO/IEC/TS 18661-2:2015 does not cover binary floating-point arithmetic (which is covered in ISO/IEC/TS 18661-1), nor does it cover most optional features of IEC 60559.
ISO/IEC TS 18661-2:2015 is classified under the following ICS (International Classification for Standards) categories: 35.060 - Languages used in information technology. The ICS classification helps identify the subject area and facilitates finding related standards.
ISO/IEC TS 18661-2:2015 has the following relationships with other standards: It is inter standard links to ISO/IEC TS 18661-2:2015. Understanding these relationships helps ensure you are using the most current and applicable version of the standard.
You can purchase ISO/IEC TS 18661-2:2015 directly from iTeh Standards. The document is available in PDF format and is delivered instantly after payment. Add the standard to your cart and complete the secure checkout process. iTeh Standards is an authorized distributor of ISO standards.
Standards Content (Sample)
TECHNICAL ISO/IEC TS
SPECIFICATION 18661-2
First edition
2015-02-15
Information Technology —
Programming languages, their
environments, and system software
interfaces — Floating-point
extensions for C —
Part 2:
Decimal floating-point arithmetic
Technologies de l’information — Langages de programmation, leurs
environnements et interfaces du logiciel système — Extensions à
virgule flottante pour C —
Partie 2: Arithmétique décimal en virgule flottante
Reference number
©
ISO/IEC 2015
© ISO/IEC 2015
All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized otherwise in any form
or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior
written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of
the requester.
ISO copyright office
Case postale 56 • CH-1211 Geneva 20
Tel. + 41 22 749 01 11
Fax + 41 22 749 09 47
E-mail copyright@iso.org
Web www.iso.org
Published in Switzerland
ii © ISO/IEC 2015 – All rights reserved
Foreword .iv
Introduction .v
1 Scope . 1
2 Conformance . 1
3 Normative references . 1
4 Terms and definitions . 1
5 C standard conformance . 2
5.1 Freestanding implementations . 2
5.2 Predefined macros . 2
5.3 Standard headers . 3
6 Decimal floating types .10
7 Characteristics of decimal floating types .11
8 Operation binding .15
9 Conversions .16
9.1 Conversions between decimal floating and integer types .16
9.2 Conversions among decimal floating types, and between decimal floating and
standard floating types .17
9.3 Conversions between decimal floating and complex types.18
9.4 Usual arithmetic conversions .18
9.5 Default argument promotion .18
10 Constants .18
11 Arithmetic operations.19
11.1 Operators .19
11.2 Functions .20
11.3 Conversions .21
11.4 Expression transformations .21
12 Library .21
12.1 Standard headers .21
12.2 Decimal floating-point environment in .21
12.3 Decimal mathematics in .25
12.4 Decimal-only functions in .34
12.4.1 Quantum and quantum exponent functions .34
12.4.2 Decimal re-encoding functions .36
12.5 Formatted input/output specifiers .38
12.6 strtodN functions in .40
12.7 wcstodN functions in .43
12.8 strfromdN functions in .44
12.9 Type-generic math for decimal in .45
Bibliography .50
© ISO/IEC 2015 – All rights reserved iii
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical
Commission) form the specialized system for worldwide standardization. National bodies that are
members of ISO or IEC participate in the development of International Standards through technical
committees established by the respective organization to deal with particular fields of technical
activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international
organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the
work. In the field of information technology, ISO and IEC have established a joint technical committee,
ISO/IEC JTC 1.
The procedures used to develop this document and those intended for its further maintenance are
described in the ISO/IEC Directives, Part 1. In particular the different approval criteria needed for
the different types of document should be noted. This document was drafted in accordance with the
editorial rules of the ISO/IEC Directives, Part 2 (see www.iso.org/directives).
Attention is drawn to the possibility that some of the elements of this document may be the subject
of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights.
Details of any patent rights identified during the development of the document will be in the Introduction
and/or on the ISO list of patent declarations received (see www.iso.org/patents).
Any trade name used in this document is information given for the convenience of users and does not
constitute an endorsement.
For an explanation on the meaning of ISO specific terms and expressions related to conformity
assessment, as well as information about ISO’s adherence to the WTO principles in the Technical Barriers
to Trade (TBT) see the following URL: Foreword - Supplementary information
The committee responsible for this document is ISO/IEC JTC 1, Information technology, Subcommittee,
SC 22, Programming languages, their environments, and system software interfaces.
ISO/IEC/TS 18661 consists of the following parts, under the general title Information technology—
Programming languages, their environments, and system software interfaces — Floating-point extensions for C:
— Part 1: Binary floating-point arithmetic
— Part 2: Decimal floating-point arithmetic
The following parts are under preparation:
— Part 3: Interchange and extended types
— Part 4: Supplementary functions
— Part 5: Supplementary attributes
ISO/IEC/TS 18661-1 updates ISO/IEC 9899:2011, Information technology — Programming Language
C, Annex F in particular to support all required features of ISO/IEC/IEEE 60559:2011, Information
technology — Microprocessor Systems — Floating-point arithmetic.
ISO/IEC/TS 18661-2 supersedes ISO/IEC/TR 24732:2009, Information technology — Programming
languages, their environments and system software interfaces — Extension for the programming language
C to support decimal floating-point arithmetic.
ISO/IEC/TS 18661-3, ISO/IEC TS 18661-4, and ISO/IEC TS 18661-5 specify extensions to ISO/IEC 9899:2011
for features recommended in ISO/IEC/IEEE 60559:2011.
iv © ISO/IEC 2015 – All rights reserved
Introduction
Background
IEC 60559 floating-point standard
The IEEE 754:1985 standard for binary floating-point arithmetic was motivated by an expanding diversity
in floating-point data representation and arithmetic which made writing robust programs, debugging,
and moving programs between systems exceedingly difficult. Now, the great majority of systems provide
data formats and arithmetic operations according to this International Standard. The IEC 60559:1989
international standard is equivalent to IEEE 754-1985 standard. Its stated goals are the following:
a) facilitate movement of existing programs from diverse computers to those that adhere to this
International Standard;
b) enhance the capabilities and safety available to programmers who, though not expert in numerical
methods, can well be attempting to produce numerically sophisticated programs. However, we
recognize that utility and safety are sometimes antagonists;
c) encourage experts to develop and distribute robust and efficient numerical programs that are
portable, by way of minor editing and recompilation, onto any computer that conforms to this
International Standard and possesses adequate capacity. When restricted to a declared subset of
the standard, these programs should produce identical results on all conforming systems;
d) provide direct support for
1) execution-time diagnosis of anomalies,
2) smoother handling of exceptions, and
3) interval arithmetic at a reasonable cost;
e) provide for the development of
1) standard elementary functions such as exp and cos,
2) very high precision (multiword) arithmetic, and
3) coupling of numerical and symbolic algebraic computation;
f) enable rather than preclude further refinements and extensions.
To these ends, the standard specified a floating-point model comprised of the following:
— formats – for binary floating-point data, including representations for Not-a-Number (NaN) and
signed infinities and zeros;
— operations – basic arithmetic operations (addition, multiplication, etc.) on the format data to compose
a well-defined, closed arithmetic system; also specified conversions between floating-point formats
and decimal character sequences, and a few auxiliary operations;
— context – status flags for detecting exceptional conditions (invalid operation, division by zero,
overflow, underflow, and inexact) and controls for choosing different rounding methods.
The ISO/IEC/IEEE 60559:2011 international standard is equivalent to the IEEE 754-2008 standard for
floating-point arithmetic which is a major revision to IEEE 754-1985.
The revised standard specifies more formats including decimal as well as binary. It adds a 128-bit binary
format to its basic formats. It also defines extended formats for all of its basic formats. It then specifies
data interchange formats (which may or may not be arithmetic), including a 16-bit binary format and an
unbounded tower of wider formats. To conform to the floating-point standard, an implementation must
provide at least one of the basic formats, along with the required operations.
© ISO/IEC 2015 – All rights reserved v
The revised standard specifies more operations. New requirements include, among others, arithmetic
operations that round their result to a narrower format than the operands (with just one rounding),
more conversions with integer types, more classifications and comparisons, and more operations for
managing flags and modes. New recommendations include an extensive set of mathematical functions
and seven reduction functions for sums and scaled products.
The revised standard places more emphasis on the reproducible results which is reflected in its
standardization of more operations. For most parts, behaviors are completely specified. The standard
requires conversions between floating-point formats and decimal character sequences to be correctly
rounded for at least three more decimal digits than what is required to distinguish all numbers in the
widest supported binary format. It also fully specifies conversions involving any number of decimal
digits. It then recommends that transcendental functions be correctly rounded.
The revised standard requires a way to specify a constant rounding direction for a static portion of code
with details left to programming language standards. This feature potentially allows rounding control
without incurring the overhead of runtime access to a global (or thread) rounding mode.
Other features recommended by the revised standard include alternate methods for exception handling,
controls for expression evaluation (allowing or disallowing various optimizations), support for fully
reproducible results, and support for program debugging.
The revised standard, like its predecessor, defines its model of floating-point arithmetic in the abstract. It
neither defines the way in which operations are expressed (which might vary depending on the computer
language or other interface being used), nor does it define the concrete representation (specific layout
in storage or in a processor’s register, for example) of data or context, except that it does define specific
encodings that are to be used for data that can be exchanged between different implementations that
conform to the specification.
IEC 60559 does not include bindings of its floating-point model for particular programming languages.
However, the revised standard does include guidance for programming language standards in recognition
of the fact that features of the floating-point standard, even if well supported in the hardware, are not
available to users unless the programming language provides a commensurate level of support. The
implementation’s combination of both hardware and software determines conformance to the floating-
point standard.
C support for IEC 60559
The C standard specifies floating-point arithmetic using an abstract model. The representation of
a floating-point number is specified in an abstract form where the constituent components (sign,
exponent, significand) of the representation are defined, but not the internals of these components. In
particular, the exponent range, significand size, and the base (or radix) are implementation-defined.
This allows flexibility for an implementation to take advantage of its underlying hardware architecture.
Furthermore, certain behaviors of operations are also implementation-defined, for example in the area
of handling of special numbers and in exceptions.
The reason for this approach is historical. At the time when C was first standardized, before the floating-
point standard was established, there were various hardware implementations of floating-point
arithmetic in common use. Specifying the exact details of a representation would have made most of the
existing implementations at the time not conforming.
Beginning with ISO/IEC 9899:1999, (C99), C has included an optional second level of specification for
implementations supporting the floating-point standard. C99, in conditionally normative Annex F,
introduced nearly complete support for the IEC 60559:1989 standard for binary floating-point arithmetic.
Also, C99’s informative Annex G offered a specification of complex arithmetic that is compatible with
IEC 60559:1989.
ISO/IEC 9899:2011, (C11) includes refinements to the C99 floating-point specification, though it is still
based on IEC 60559. C11:1989 upgraded Annex G from “informative” to “conditionally normative”.
ISO/IEC/TR 24732:2009 introduced partial C support for the decimal floating-point arithmetic in
ISO/IEC/IEEE 60559:2011. ISO/IEC/TR 24732, for which technical content was completed while
vi © ISO/IEC 2015 – All rights reserved
IEEE 754-2008 was still in the later stages of development, specifies decimal types based on ISO/IEC/
IEEE 60559:2011 decimal formats, though it does not include all of the operations required by ISO/IEC/
IEEE 60559:2011.
Purpose
The purpose of this International Standard is to provide a C language binding for ISO/IEC/IEEE 60559:2011
based on the C11 standard that delivers the goals of ISO/IEC/IEEE 60559 to users and is feasible to be
implemented. It is then organized into five parts.
ISO/IEC/TS 18661-1 provides changes to C11 that cover all the requirements plus some basic
recommendations of ISO/IEC/IEEE 60559:2011 for binary floating-point arithmetic. C implementations
intending to support ISO/IEC/IEEE 60559:2011 are expected to conform to conditionally normative
Annex F as enhanced by the changes in ISO/IEC TS 18661-1.
ISO/IEC/TS 18661-2 enhances ISO/IEC/TR 24732 to cover all the requirements plus some basic
recommendations of ISO/IEC/IEEE 60559:2011 for decimal floating-point arithmetic. C implementations
intending to provide an extension for decimal floating-point arithmetic supporting ISO/IEC/
IEEE 60559:2011 are expected to conform to ISO/IEC TS 18661-2.
ISO/IEC/TS 18661-3 (Interchange and extended types), ISO/IEC/TS 18661-4 (Supplementary functions),
and ISO/IEC/TS 18661-5 (Supplementary attributes) cover recommended features of ISO/IEC/
IEEE 60559:2011. C implementations intending to provide extensions for these features are expected to
conform to the corresponding parts.
Additional background on decimal floating-point arithmetic
Most of today’s general-purpose computing architectures provide binary floating-point arithmetic in
hardware. Binary floating point is an efficient representation that minimizes memory use and is simpler
to implement than floating-point arithmetic using other bases. It has therefore become the norm for
scientific computations with almost all implementations following the IEEE 754 standard for binary
floating-point arithmetic (and the equivalent international ISO/IEC/IEEE 60559 standard).
However, human computation and communication of numeric values almost always uses decimal
arithmetic and decimal notations. Laboratory notes, scientific papers, legal documents, business
reports, and financial statements all record numeric values in decimal form. When numeric data are
given to a program or are displayed to a user, conversion between binary and decimal is required. There
are inherent rounding errors involved in such conversions. Decimal fractions cannot, in general, be
represented exactly by binary floating-point values. These errors often cause usability and efficiency
problems depending on the application.
These problems are minor when the application domain accepts or requires results to have associated
error estimates (as is the case with scientific applications). However, in business and financial
applications, computations are either required to be exact (with no rounding errors), unless explicitly
rounded or supported by detailed analyses that are auditable to be correct. Such applications therefore
have to take special care in handling any rounding errors introduced by the computations.
The most efficient way to avoid conversion error is to use decimal arithmetic. Currently, the IBM
z/Architecture (and its predecessors since System/360) is a widely used system that supports built-in
decimal arithmetic. Prior to the IBM System z10 processor, however, this provided integer arithmetic
only, meaning that every number and computation has to have separate scale information preserved
and computed in order to maintain the required precision and value range. Such scaling is difficult to
code and is error-prone. It also affects execution time significantly and the resulting program is often
difficult to maintain and enhance.
Eventhough the hardware might not provide decimal arithmetic operations, the support can still
be emulated by software. Programming languages used for business applications either have native
decimal types (such as PL/I, COBOL, REXX, C#, or Visual Basic) or provide decimal arithmetic libraries
(such as the BigDecimal class in Java). The arithmetic used in business applications, nowadays, is almost
invariably decimal floating-point. The COBOL 2002 ISO standard, for example, requires that all standard
decimal arithmetic calculations use 32-digit decimal floating-point.
© ISO/IEC 2015 – All rights reserved vii
The IEEE has recognized this importance. Decimal floating-point formats and arithmetic are major new
features in the IEEE 754-2008 standard and its international equivalent ISO/IEC/IEEE 60559:2011.
viii © ISO/IEC 2015 – All rights reserved
TECHNICAL SPECIFICATION ISO/IEC TS 18661-2:2015(E)
Information Technology — Programming languages, their
environments, and system software interfaces — Floating-
point extensions for C —
Part 2:
Decimal floating-point arithmetic
1 Scope
This part of ISO/IEC/TS 18661 extends programming language C as specified in ISO/IEC 9899:2011,
(C11) with changes specified in ISO/IEC/TS 18661-1, to support decimal floating-point arithmetic
conforming to ISO/IEC/IEEE 60559:2011. It covers all requirements of IEC 60559 as they pertain to C
decimal floating types.
This part of ISO/IEC/TS 18661 supersedes ISO/IEC/TR 24732:2009.
This part of ISO/IEC/TS 18661 does not cover binary floating-point arithmetic (which is covered in
ISO/IEC/TS 18661-1), nor does it cover most optional features of IEC 60559.
2 Conformance
An implementation conforms to this part of ISO/IEC/TS 18661 if
a) it meets the requirements for a conforming implementation of C11 with all the changes to C11
specified in ISO/IEC/TS 18661-1 and in this part of ISO/IEC/TS 18661, and
b) it defines __STDC_IEC_60559_DFP__ to 201ymmL.
NOTE Conformance to this part of ISO/IEC/TS 18661 does not include all the requirements of ISO/IEC/TS 18661-
1. An implementation can conform to either or both of ISO/IEC/TS 18661-1 and this part of ISO/IEC/TS 18661.
3 Normative references
The following documents, in whole or in part, are normatively referenced in this document and are
indispensable for its application. For dated references, only the edition cited applies. For undated
references, the latest edition of the referenced document (including any amendments) applies.
ISO/IEC 9899:2011, Information technology — Programming languages — C
ISO/IEC/IEEE 60559:2011, Information technology — Microprocessor Systems — Floating-Point arithmetic
ISO/IEC/TS 18661-1, Information technology — Programming languages, their environments, and system
software interfaces — Floating-point extensions for C — Part 1: Binary floating-point arithmetic
4 Terms and definitions
For the purposes of this document, the terms and definitions given in ISO/IEC 9899:2011, ISO/IEC/
IEEE 60559:2011, and the following apply.
© ISO/IEC 2015 – All rights reserved 1
4.1
C11
standard ISO/IEC 9899:2011, Information technology — Programming languages C, including Technical
Corrigendum 1 (ISO/IEC 9899-1:2011/Cor:2012)
5 C standard conformance
5.1 Freestanding implementations
The following change to C11 + TS18661-1 expands the conformance requirements for freestanding
implementations so that they might conform to this part of ISO/IEC/TS 18661.
Change to C11 + TS18661-1:
Replace the fourth sentence of 4#6:
The strictly conforming programs that shall be accepted by a conforming freestanding
implementation that defines __STDC_IEC_60559_BFP__ may also use features in the contents
of the standard headers and and the numeric conversion functions (7.22.1)
of the standard header .
with:
The strictly conforming programs that shall be accepted by a conforming freestanding
implementation that defines __STDC_IEC_60559_BFP__ or __STDC_IEC_60559_DFP__
may also use features in the contents of the standard headers and and the
numeric conversion functions (7.22.1) of the standard header .
5.2 Predefined macros
The following change to C11 + TS18661-1 replaces __STDC_DEC_FP__, the conformance macro for
decimal floating-point arithmetic specified in TR 24732, with __STDC_IEC_60559_DFP__, for
consistency with the conformance macro for ISO/IEC/TS 18661-1. Note that an implementation may
continue to define __STDC_DEC_FP__, so that programs that use __STDC_DEC_FP__ may remain
valid under the changes in Part 2 of Technical Specification 18661.
Change to C11 + TS18661-1:
In 6.10.8.3#1, add:
__STDC_IEC_60559_DFP__ The integer constant 201ymmL, intended to indicate support of
decimal floating types and conformance with Annex F for IEC 60559 decimal floating-point arithmetic.
The following change to C11 + TS18661-1 specifies the applications of Annex F to binary and decimal
floating-point arithmetic.
Change to C11 + TS18661-1:
Replace F.1#3:
[3] An implementation that defines __STDC_IEC_60559_BFP__ to 201ymmL shall conform to
the specifications in this Annex.356) Where a binding between the C language and IEC 60559 is
indicated, the IEC 60559-specified behavior is adopted by reference, unless stated otherwise.
with:
[3] An implementation that defines __STDC_IEC_60559_BFP__ to 201ymmL shall conform to the
specifications in this annex for binary floating-point arithmetic.356)
2 © ISO/IEC 2015 – All rights reserved
[4] An implementation that defines __STDC_IEC_60559_DFP__ to 201ymmL shall conform to the
specifications for decimal floating-point arithmetic in the following subclauses of this annex:
— F.2.1 Infinities and NaNs
— F.3 Operations
— F.4 Floating to integer conversions
— F.6 The return statement
— F.7 Contracted expressions
— F.8 Floating-point environment
— F.9 Optimization
— F.10 Mathematics
For the purpose of specifying these conformance requirements, the macros, functions, and values
mentioned in the subclauses listed above are understood to refer to the corresponding macros,
functions, and values for decimal floating types. Likewise, the “rounding direction mode” is
understood to refer to the rounding direction mode for decimal floating-point arithmetic.
[5] Where a binding between the C language and IEC 60559 is indicated, the IEC 60559-specified
behavior is adopted by reference, unless stated otherwise.
5.3 Standard headers
The new identifiers added to C11 library headers by this part of ISO/IEC/TS 18661 are defined or
declared by their respective headers only if __STDC_WANT_IEC_60559_DFP_EXT__ is defined as a
macro at the point in the source file where the appropriate header is first included. The macro __STDC_
WANT_IEC_60559_DFP_EXT__ replaces the macro __STDC_WANT_DEC_FP__ specified in TR 24732
for the same purpose. The following changes to C11 + TS18661-1 list these identifiers in each applicable
library subclause.
Changes to C11 + TS18661-1:
In 5.2.4.2.1#1a, change:
[1a] The following identifiers are defined only if __STDC_WANT_IEC_60559_BFP_EXT__ is
defined as a macro at the point in the source file where is first included:
to:
[1a] The following identifiers are defined only if __STDC_WANT_IEC_60559_BFP_EXT__ or __
STDC_WANT_IEC_60559_DFP_EXT__ is defined as a macro at the point in the source file where
is first included:
After 5.2.4.2.2#6a, insert the paragraph:
[6b] The following identifiers are defined only if __STDC_WANT_IEC_60559_DFP_EXT__ is
defined as a macro at the point in the source file where is first included:
for N = 32, 64, and 128:
DECN_MANT_DIG DECN_MAX DECN_TRUE_MIN
DECN_MIN_EXP DECN_EPSILON
DECN_MAX_EXP DECN_MIN
After 7.6#3a, insert the paragraph:
© ISO/IEC 2015 – All rights reserved 3
[3b] The following identifiers are declared only if __STDC_WANT_IEC_60559_DFP_EXT__ is
defined as a macro at the point in the source file where is first included:
fe_dec_getround fe_dec_setround
Change 7.12#1a from:
[1a] The following identifiers are defined or declared only if __STDC_WANT_IEC_60559_BFP_
EXT__ is defined as a macro at the point in the source file where is first included:
FP_INT_UPWARD FP_FAST_FSUB
FP_INT_DOWNWARD FP_FAST_FSUBL
FP_INT_TOWARDZERO FP_FAST_DSUBL
FP_INT_TONEAREST- FP_FAST_FMUL
FROMZERO
FP_INT_TONEAREST FP_FAST_FMULL
FP_LLOGB0 FP_FAST_DMULL
FP_LLOGBNAN FP_FAST_FDIV
SNANF FP_FAST_FDIVL
SNAN FP_FAST_DDIVL
SNANL FP_FAST_FSQRT
FP_FAST_FADD FP_FAST_FSQRTL
FP_FAST_FADDL FP_FAST_DSQRTL
FP_FAST_DADDL
iseqsig fmaxmagf ffmal
iscanonical fmaxmagl dfmal
issignaling fminmag fsqrt
issubnormal fminmagf fsqrtl
iszero fminmagl dsqrtl
fromfp nextup totalorder
fromfpf nextupf totalorderf
fromfpl nextupl totalorderl
ufromfp nextdown totalordermag
ufromfpf nextdownf totalordermagf
ufromfpl nextdownl totalordermagl
fromfpx fadd canonicalize
fromfpxf faddl canonicalizef
fromfpxl daddl canonicalizel
4 © ISO/IEC 2015 – All rights reserved
ufromfpx fsub getpayload
ufromfpxf fsubl getpayloadf
ufromfpxl dsubl getpayloadl
roundeven fmul setpayload
roundevenf fmull setpayloadf
roundevenl dmull setpayloadl
llogb fdiv setpayloadsig
llogbf fdivl setpayloadsigf
llogbl ddivl setpayloadsigl
fmaxmag ffma
to:
[1a] The following identifiers are defined only if __STDC_WANT_IEC_60559_BFP_EXT__ or __
STDC_WANT_IEC_60559_DFP_EXT__ is defined as a macro at the point in the source file where
is first included:
FP_INT_UPWARD FP_LLOGBNAN
FP_INT_DOWNWARD iseqsig
FP_INT_TOWARDZERO iscanonical
FP_INT_TONEARESTFROMZERO issignaling
FP_INT_TONEAREST issubnormal
FP_LLOGB0 iszero
[1b] The following identifiers are defined or declared only if __STDC_WANT_IEC_60559_BFP_
EXT__ is defined as a macro at the point in the source file where is first included:
SNANF ufromfpxf dmull
SNAN ufromfpxl fdiv
SNANL roundeven fdivl
FP_FAST_FADD roundevenf ddivl
FP_FAST_FADDL roundevenl ffma
FP_FAST_DADDL llogb ffmal
FP_FAST_FSUB llogbf dfmal
FP_FAST_FSUBL llogbl fsqrt
FP_FAST_DSUBL fmaxmag fsqrtl
FP_FAST_FMUL fmaxmagf dsqrtl
FP_FAST_FMULL fmaxmagl totalorder
© ISO/IEC 2015 – All rights reserved 5
FP_FAST_DMULL fminmag totalorderf
FP_FAST_FDIV fminmagf totalorderl
FP_FAST_FDIVL fminmagl totalordermag
FP_FAST_DDIVL nextup totalordermagf
FP_FAST_FSQRT nextupf totalordermagl
FP_FAST_FSQRTL nextupl canonicalize
FP_FAST_DSQRTL nextdown canonicalizef
fromfp nextdownf canonicalizel
fromfpf nextdownl getpayload
fromfpl fadd getpayloadf
ufromfp faddl getpayloadl
ufromfpf daddl setpayload
ufromfpl fsub setpayloadf
fromfpx fsubl setpayloadl
fromfpxf dsubl setpayloadsig
fromfpxl fmul setpayloadsigf
ufromfpx fmull setpayloadsigl
[1c] The following identifiers are defined or declared only if __STDC_WANT_IEC_60559_DFP_
EXT__ is defined as a macro at the point in the source file where is first included:
_Decimal32_t DEC_INFINITY
_Decimal64_t DEC_NAN
and for N = 32, 64, 128:
HUGE_VAL_DN modfdN remainderdN
SNANDN scalbndN copysigndN
FP_FAST_FMADN scalblndN nandN
acosdN cbrtdN nextafterdN
asindN fabsdN nexttowarddN
atandN hypotdN nextupdN
atan2dN powdN nextdowndN
cosdN sqrtdN canonicalizedN
sindN erfdN fdimdN
tandN erfcdN fmaxdN
6 © ISO/IEC 2015 – All rights reserved
acoshdN lgammadN fmindN
asinhdN tgammadN fmaxmagdN
atanhdN ceildN fminmagdN
coshdN floordN fmadN
sinhdN nearbyintdN totalorderdN
tanhdN rintdN totalordermagdN
expdN lrintdN getpayloaddN
exp2dN llrintdN setpayloaddN
expm1dN rounddN setpayloadsigdN
frexpdN lrounddN quantizedN
ilogbdN llrounddN samequantumdN
llogbdN truncdN quantumdN
ldexpdN roundevendN llquantexpdN
logdN fromfpdN encodedecdN
log10dN ufromfpdN decodedecdN
log1pdN fromfpxdN encodebindN
log2dN ufromfpxdN decodebindN
logbdN fmoddN
and for (M,N) = (32,64), (32,128), (64,128):
FP_FAST_DMADDDN FP_FAST_DMFMADN dMmuldN
FP_FAST_DMSUBDN FP_FAST_DMSQRTDN dMdivdN
FP_FAST_DMMULDN dMadddN dMfmadN
FP_FAST_DMDIVDN dMsubdN dMsqrtdN
In 7.20#4a, change:
[4a] The following identifiers are defined only if __STDC_WANT_IEC_60559_BFP_EXT__ is
defined as a macro at the point in the source file where is first included:
to:
[4a] The following identifiers are defined only if __STDC_WANT_IEC_60559_BFP_EXT__ or __
STDC_WANT_IEC_60559_DFP_EXT__ is defined as a macro at the point in the source file where
is first included:
After 7.22#1a, insert the paragraph:
[1b] The following identifiers are declared only if __STDC_WANT_IEC_60559_DFP_EXT__ is
defined as a macro at the point in the source file where is first included:
strfromd32 strfromd128 strtod64
© ISO/IEC 2015 – All rights reserved 7
strfromd64 strtod32 strtod128
8 © ISO/IEC 2015 – All rights reserved
Change 7.25#1a from:
[1a] The following identifiers are defined as type-generic macros only if __STDC_WANT_
IEC_60559_BFP_EXT__ is defined as a macro at the point in the source file where
is first included:
roundeven fromfpx fmul
llogb ufromfpx dmul
fmaxmag totalorder fdiv
fminmag totalordermag ddiv
nextup fadd ffma
nextdown dadd dfma
fromfp fsub fsqrt
ufromfp dsub dsqrt
to:
[1a] The following identifiers are defined as type-generic macros only if __STDC_WANT_
IEC_60559_BFP_EXT__ or __STDC_WANT_IEC_60559_DFP_EXT__ is defined as a macro at
the point in the source file where is first included:
roundeven nextup fromfpx
llogb nextdown ufromfpx
fmaxmag fromfp totalorder
fminmag ufromfp totalordermag
[1b] The following identifiers are defined as type-generic macros only if __STDC_WANT_
IEC_60559_BFP_EXT__ is defined as a macro at the point in the source file where
is first included:
fadd fmul ffma
dadd dmul dfma
fsub fdiv fsqrt
dsub ddiv dsqrt
[1c] The following identifiers are defined as type-generic macros only if __STDC_WANT_
IEC_60559_DFP_EXT__ is defined as a macro at the point in the source file where
is first included:
d32add d64add quantize
d32sub d64sub samequantum
d32mul d64mul quantum
d32div d64div llquantexp
d32fma d64fma
d32sqrt d64sqrt
© ISO/IEC 2015 – All rights reserved 9
6 Decimal floating types
This part of ISO/IEC/TS 18661 introduces three decimal floating types, designated as _Decimal32,
_Decimal64 and _Decimal128. These types support the IEC 60559 decimal formats: decimal32,
decimal64, and decimal128.
Within the type hierarchy, decimal floating types are basic types, real types, and arithmetic types.
This part of ISO/IEC/TS 18661 introduces the term standard floating types to refer to the types float,
double, and long double, which are the floating types the C Standard requires unconditionally.
NOTE C does not specify a radix for float, double, and long double. An implementation can choose the
representation of float, double, and long double to be the same as the decimal floating types. Regardless of
the representation, the decimal floating types are distinct from the types float, double, and long double.
NOTE This part of ISO/IEC/TS 18661 does not define decimal complex types or decimal imaginary types. The
three complex types remain as float _Complex, double _Complex, and long double _Complex, and the
three imaginary types remain as float _Imaginary, double _Imaginary, and long double _Imaginary.
Changes to C11 + TS18661-1:
Change the first sentence of 6.2.5#10 from:
[10] There are three real floating types, designated as float, double, and long double.
to:
[10] There are three standard floating types, designated as float, double, and long double.
Add the following paragraphs after 6.2.5#10:
[10a] There are three decimal floating types, designated as _Decimal32, _Decimal64, and
_Decimal128. Respectively, they have the IEC 60559 formats: decimal32, decimal64, and
decimal128. Decimal floating types are real floating types.
[10b] The standard floating types and the decimal floating types are collectively called the real
floating types.
In 6.2.5#10a, attach a footnote to the wording:
they have the IEC 60559 formats: decimal32
where the footnote is:
*) IEC 60559 specifies decimal32 as a data-interchange format that does not require arithmetic
support; however, _Decimal32 is a fully supported arithmetic type.
Add the following to 6.4.1 Keywords:
keyword:
_Decimal32
_Decimal64
_Decimal128
Add the following to 6.7.2 Type specifiers:
type-specifier:
_Decimal32
_Decimal64
_Decimal128
10 © ISO/IEC 2015 – All rights reserved
Add the following bullets in 6.7.2#2 Constraints:
— _Decimal32
— _Decimal64
— _Decimal128
Add the following after 6.7.2#3:
[3a] The type specifiers _Decimal32, _Decimal64, and _Decimal128 shall not be used if the
implementation does not support decimal floating types (see 6.10.8.3).
Add the following after 6.5#8:
[8a] Operators involving decimal floating types are evaluated according to the semantics of IEC 60559,
including production of results with the preferred quantum exponent as specified in IEC 60559.
7 Characteristics of decimal floating types
IEC 60559 defines a general model for floating-point data, specifies formats (both binary and decimal)
for the data, and defines encodings for the formats.
The three decimal floating types correspond to decimal formats defined in IEC 60559 as follows:
— _Decimal32 is a decimal32 format, which is encoded in 32 bits
— _Decimal64 is a decimal64 format, which is encoded in 64 bits
— _Decimal128 is a decimal128 format, which is encoded in 128 bits
sign exponent
The value of a finite number is given by (−1) x significand x 10 . Refer to IEC 60559 for details
of the format.
These formats are characterized by the length of the significand and the maximum exponent. Note that,
for decimal IEC 60559 decimal formats, trailing zeros in the significand are significant; i.e., 1.0 is equal
to but can be distinguished from 1.00. The table below shows these characteristics by type:
Format characteristics
_Decimal32 _Decimal64 _Decimal128
Type
Significand length in digits 7 16 34
Maximum Exponent (E ) 97 385 6 145
max
Minimum Exponent (E ) −94 −382 −6 142
min
The maximum and minimum exponents in the table are for floating-point numbers expressed with
significands less than 1, as in the C11 model (5.2.4.2.2). They differ (by 1) from the maximum and
minimum exponents in the IEC 60559 standard, where normalized floating-point numbers are expressed
with one significant digit to the left of the radix point.
If the macro __STDC_WANT_IEC_60559_DFP_EXT__ is defined at the point in the source file where
the header is first included, the header shall define several macros that expand
to various limits and parameters of the decimal floating types. The names and meaning of these macros
are similar to the corresponding macros for standard floating types.
Changes to C11 + TS18661-1:
In 5.2.4.2.2#6, append the sentence:
Decimal floating-point operations have stricter requirements.
© ISO/IEC 2015 – All rights reserved 11
In 5.2.4.2.2#7, change:
All except CR_DECIMAL_DIG (F.5), DECIMAL_DIG, FLT_EVAL_METHOD, FLT_RADIX.
and FLT_ROUNDS have separate names for all three floating-point types. The floating- point model
representation is provided for all values except FLT_EVAL_METHOD and FLT_ROUNDS.
to:
All except CR_DECIMAL_DIG (F.5), DECIMAL_DIG, DEC_EVAL_METHOD, FLT_EVAL_
METHOD, FLT_RADIX, and FLT_ROUNDS have separate names for all real floating types. The
floating-point model representation is provided for all values except DEC_EVAL_METHOD, FLT_
EVAL_METHOD, and FLT_ROUNDS.
After 5.2.4.2.2#7, insert the paragraph:
[7a] The remainder of this subclause specifies characteristics of standard floating types.
In 5.2.4.2.2#8, change:
[8] The rounding mode for floating-point addition is characterized by the implementation-defined
value of FLT_ROUNDS
to:
[8] The rounding mode for floating-point addition for standard floating types is characterized by
the
...








Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.
Loading comments...