Syntactic Support for IEEE 754r Binary128 and Decimal128 Formats

advertisement
February 11, 2004
Document Number:
J4/05-0047
Page
Subject:
Syntactic Support for IEEE 754r Binary128 and Decimal128 Formats
Author:
Charles C. Stevens
1 of 21
References in Document:
1) ISO/IEC 1989:2002, Programming language COBOL 20xx -- Base Document for
20xx standard (Nelson) (1/29/2005)
2) Draft Standard for Floating-Point Arithmetic P754 (see http://754r.ucbtest.org/ for
current draft)
Previous version of document:
04-0251 – Syntactic Support for IEEE 754r Binary128 and Decimal128 Formats
(Stevens)
Note that the history of discussions about and modifications of this document
between its initial composition and the beginning of Meeting #249a is contained
in this prior version of the document.
Discussion of Project:
WG4 directed at Meeting #25 that this issue be explored further, and the author has
volunteered to prepare a draft of a specification that can be incorporated into the
proposed 2008 draft.
IEEE 754 is being revised to add a 128-bit binary floating-point representation, as well
as three decimal floating-point representations, namely, decimal32, decimal64 and
decimal128.
The details of these formats are under the purview of IEEE, and it is the specific intent of
the author that COBOL be able to make use of the arithmetic, format and rounding rules
for operands in these formats as detailed by that organization.
The author suspects that the draft version of IEEE 754 will ultimately be the basis for a
revision to ISO/IEC 10967-1:1994 – Language independent arithmetic – Part 1: integer
and floating-point arithmetic, and this first draft of the proposal presumes this eventuality.
This is reflected by references to “ISO/IEC 10967-1:20xx” which does not yet exist, and
the paragraph numbers are as found in Reference 2. [NOTE: As of Document 05-0006,
this approach has been abandoned; references to the subject document are in the form
“DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29
20:00” thereafter.] It is currently expected that the revisions to IEEE 754 will be
published as a new standard in 2005.
The ultimate goal of this proposal is to provide arithmetic *in COBOL* for which the rules
of rounding and result formation for basic arithmetic are entirely covered by an
February 11, 2004
Document Number:
J4/05-0047
Page
2 of 21
international standard for arithmetic rather than being unique to COBOL and specified
therein.
There are several parts to this proposal that might be considered independently:
1) 128-bit binary and decimal floating-point USAGE formats as proposed for the IEEE
754 revision.
2) Allow use of 128-bit binary and decimal floating-point for intermediate data items
(SBIDI and SDIDI in addition to currently-specified SIDI) through new ARITHMETIC
IS STANDARD-BINARY and ARITHMETIC IS STANDARD-DECIMAL alongside
current ARITHMETIC IS NATIVE and ARITHMETIC IS STANDARD. Arithmetic
rules for the new intermediate formats are as specified in the IEEE 754 proposal.
3) 32-bit and 64-bit binary floating-point USAGE formats as currently defined in IEEE
754:1985. Some implementors may have done this with one of the FLOATUSAGEs; this allows the choice to be both fixed and portable (to all systems that
provide them).
4) 32-bit and 64-bit decimal floating-point USAGE formats as proposed for the IEEE
754 revision. The author doesn't think they'll be of that much use, but while we're at
it …
5) Allow new ROUNDED clauses to cover current truncation (ROUNDED TO ZERO),
current rounding away from zero (ROUNDED FROM ZERO) , new rounding with
ties to even (ROUNDED TO EVEN), and new explicit requirement of exact results
(raise an exception if results can't be exactly represented in the destination). In the
absence of a ROUNDED clause where one is permitted, the results are as before -truncation.
6) Allow specification in the OPTIONS paragraph of INTERMEDIATE ROUNDING
actions (currently truncation only) to include the current truncation (ROUNDED TO
ZERO), "banker's rounding" (ROUNDED TO EVEN) and prohibition of inexact
representations in intermediate results (NO ROUNDED). The default is
INTERMEDIATE ROUNDING IS ROUNDED TO ZERO. The impact of these
options on NATIVE arithmetic is implementor-defined; the impact on STANDARD
arithmetic is specified.
There are a number of rounding options in the IEEE 754 proposal; I think ultimately we
ought to provide as many options as possible in this area, both for intermediate rounding
and for individual statements. Even with the limited selections in this proposal the
wording is decidedly clumsy; ROUNDED TO EVEN is actually "short" for IEEE 754
"rounded toward nearest with ties to even", and the options include such things as
"rounded toward positive infinity". I also would like folks, in the review process, to make
sure my description of the wording options for COBOL accurately reflects the
specifications in the IEEE 754 proposal.
February 11, 2004
Document Number:
J4/05-0047
Page
3 of 21
Discussion at Meeting #249a:
1) Mr. Klein’s suggestion via e-mail to allow floating-point literals to have significands
larger than 31 digits and exponents larger than 3 digits was accepted. Significands
longer than 31 digits are a processor-dependent feature and will be so documented.
2) Mr. Klein’s suggestion via e-mail to allow floating-point edited-numeric items to have
significand specifications longer than 31 digits (to 34) and exponent specifications
longer than 3 digits (to 4) was accepted. Extending the significand increase to nonfloating-point items is not being considered at this time, but we should check with
SQL folk to see if they will be doing so in support of IEEE 128-bit formats.
3) Mr. Klein’s suggestion to allow 34-digit significands and 4-digit exponents in the rules
for the NUMVAL-F and TEST-NUMVAL-F functions was accepted.
4) Mr. Cowlishaw’s suggestion via e-mail to include NEAREST-AWAY-FROM-ZERO as
a legitimate INTERMEDIATE ROUNDING option was accepted.
5) Mr. Cowlishaw seemed to indicate in his e-mail that TOWARD-GREATER, TOWARDLESS, AWAY-FROM-ZERO and NEAREST-TOWARD-ZERO as INTERMEDIATE
ROUNDING clauses are inappropriate in that context, and the committee agreed. For
the ROUNDED clause, however, they are being retained for compatibility and
interoperability with JAVA.
6) In ARITHMETIC IS STANDARD-BINARY, any conversion of a Standard-Binary
Intermediate Data Item to a decimal format must first convert the value into a
temporary in FLOAT-DECIMAL-34 format and then transfer that value to the
destination. That means that whether the implementation supports ARITHMETIC IS
STANDARD-DECIMAL or not, any implementation that provides support for
STANDARD-BINARY must also provide mechanisms to convert to and from a
FLOAT-DECIMAL-34 item in a manner in complete compliance with IEEE 754r rules.
(This is the resolution for Open Item #2 in 04-0251, the previous version of this
document).
7) The existing STANDARD ARITHMETIC needs to be changed to a processordependent feature and the Concepts adjusted to indicate that’s not the current
direction for COBOL.
8) It isn’t practical to make USAGE FLOAT-DECIMAL-34 require ARITHMETIC IS
STANDARD-DECIMAL or vice versa; ditto for binary. Although we hope
implementers will take on the “whole package”, the USAGEs and the ARITHMETIC IS
clauses are separately described as processor-dependent.
9) Exception handling for the various arithmetic operations and for conversions to and
from the intermediate formats needs to be investigated and clarified. Subsequent
examination of IEEE 754r suggests that individual exceptions need to be supported
for Invalid Operation (e.g., the product of infinity and zero), Division by Zero,
February 11, 2004
Document Number:
J4/05-0047
Page
4 of 21
Overflow, Underflow and Inexact. This is discussed further in Remaining Open
Issues item 1) below.
10) Use FLOAT-DECIMAL-7, FLOAT-DECIMAL-16, FLOAT-DECIMAL-34, FLOATBINARY-9, FLOAT-BINARY-16 and FLOAT-BINARY-34 for the new USAGEs. (This
is the resolution for Open Item #1 in 04-0251, the previous version of this document).
11) In addition to the 33 digits of precision specified for Decimal128, there’s another digit
in the “combination” part of the format. And since 2**113 is about 10**34, the
maximum digit specification for both standard-decimal and standard-binary arithmetic
is 34.
12) While the fact that the intermediate rounding rules for Standard Arithmetic are in one
place (under Standard Arithmetic) and those for Standard-Binary and StandardDecimal arithmetic are in another (under the Intermediate Rounding clause) there are
adequate bidirectional pointers in both places. This situation is peculiar, and may be
resolved later, but for the time being it’s not actually wrong. This closes Open Item #5
in 04-0251, the previous version of this document.
13) Floating-point literals need to allow for 34 digits of precision, as do floating-point
numeric-edited PICTURE character-strings.
14) Where different rules exist for 33 digits for FLOAT-DECIMAL-34 items and 34 for
FLOAT-BINARY-34 ITEMS, these need correcting; the maximum for both is 34.
15) The meaning of, and handling of, negative infinity, positive infinity, and Not-a-Number
values in COBOL needs to be addressed. While the author’s original suggestion was
to raise exceptions when any such value was encountered or produced, it appears
this would, as a default requirement, be inconsistent with IEEE 754r.
16) This proposal does not seem to address normalization.
Further changes and research independently done after meeting #249a:
1) The author does not feel dependencies among the various FLOAT-DECIMAL and
FLOAT-BINARY USAGEs is appropriate and has closed this possibility. Each and all
are independently processor-dependent, but ultimately the concepts section will
make this clear. This question was raised in Open Item #3 of 04-0251, the previous
version of this document. No change is needed here.
2) As this proposal has evolved, it is clear that because COBOL is fundamentally a
decimal language, support for the use of the IEEE Decimal128 format is primary and
that for Binary128 is secondary. This closes Open Item #4 of 04-0251, the previous
version of this document, and furher related issues may be found above in
Discussion at Meeting #249a.
February 11, 2004
Document Number:
J4/05-0047
Page
5 of 21
3) Many thanks to Mike Cowlishaw of IBM for his many helpful suggestions and
guidance through private email correspondence.
Discussion at Meeting #250:
The committee discussed the fact that, if standard-binary arithmetic is in effect, decimal
operands must first be converted to Binary128 form before arithmetic operations are
performed on them, and this leads to precision loss. The same is true for binary
operands (in particular the three forms of IEEE 754r binary floating-point supported in
this standard) when standard-decimal arithmetic is in effect, though this circumstance is
less likely.
The suggestion was made that the availability of USAGE FLOAT-BINARY items should
be based on the specification of ARITHMETIC IS STANDARD-BINARY. The author
feels that the ability to declare a Binary128 (or Binary64 or Binary32 for that matter) or
their Decimal equivalents is, and should be, completely independent of the manner in
which the implementor chooses to provide arithmetic operations. For example, it is
entirely possible that a programmer might wish to receive, and convert into readable
forms, items of any such usage without performing arithmetic operations on them. While
the intent of this proposal is to encourage all implementors to provide all six new
USAGEs, and both new arithmetic modes, the author does not feel the standard should
require them all. In this proposal, USAGE is, and indeed should remain, independent of
the ARITHMETIC IS specification, and the USAGEs and the two new arithmetic modes
represent independent processor-dependent features.
The suggestion was made that since all arithmetic operations involve two operands the
form of the two operands should be used to determine which form was used to produce
the result of that atomic operation -- decimal for two decimal operands, binary for two
binary operands. In the event the two operands are dissimilar forms, the form specified
in the ARITHMETIC clause is used, and the operand that does not match that form is
converted to that form.
The author believes the approach outlined in 05-0006, that all operands are converted
into the single intermediate form -- Binary128 or Decimal128 depending on the
ARITHMETIC specification -- is the correct answer. All operations are best performed
against operands in the single, consistent form specified by the user for the program as
a whole. Enhancements and variations on this approach can be considered for a future
proposal, but they are beyond the scope of this one.
.
Open issue #1 from 05-0006 is resolved by the decision to use the existing exception
conditions for floating-point exceptions.
Open issue #2 from 05-0006 is resolved by the decision to await user feedback before
considering adding these new ancillary intrinsic functions.
February 11, 2004
Document Number:
J4/05-0047
Page
6 of 21
Open issue #3 from 05-0006 is resolved by the decision that the only meaningful case in
which normalization might be important is conversion from a SDIDI or SBIDI to some
other representation, and the committee agrees that the IEEE 754r draft adequately
covers that case.
Open issue #4 from 05-0006, whether to have three, four, or eight modes of intermediate
rounding is resolved by the decision to have four intermediate rounding modes in the
current version of this proposal.
Two new open issues were raised after the publication of 05-0006.
The first new open issue is that the intrinsic functions ACOS, ASIN, ATAN, COS, EXP,
EXP10, LOG, LOG10, SIN, STANDARD-DEVIATION and TAN all indicate that their
results are approximations. The author would prefer that in the new standard arithmetic
environment these functions be specified more rigorously, but it is not clear that the
relevant ISO standards for these functions are specified in a manner that would include
the larger IEEE 754r floating-point formats. The committee has elected to leave the
returned value rules for these functions unchanged.
The second new open issue is the specific case of the SQRT intrinsic function. In this
case, IEEE 754r explicitly provides a definition for SQRT. It is not in conflict with the
current standard, but again, it is the author's preference that the COBOL standard refer
elsewhere for such functions. The committee has elected to leave the returned value
rules for these functions as currently specified in 05-0006.
Remaining open issues:
NONE.
Proposed Changes to the Draft Standard:
1. Page 2, 2. Normative references: Add the following entry:
DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29
20:00.
[Author's NOTE This reference needs to be updated as new versions of this draft
are promulgated and as the standard is adopted by IEEE and then ISO. If IEEE
does not process this through the ISO fast track procedure for standards, there
are ways to make a normative reference to it in an IEEE document.]
2. Page 74, 8.3.1.2.2.2, Floating-point numeric literals, Rule 2: Replace the third
sentence with “The significand shall be from 1 to 34 digits in length.”
February 11, 2004
Document Number:
J4/05-0047
Page
7 of 21
3. Page 74, 8.3.1.2.2.2, Floating-point numeric literals, Rule 3: Change the second
sentence in part to read “ … maximum of four …”.
4. Page 118, 8.8.1.1, Native and Standard Arithmetic:
Change the heading to read “Native, Standard, Standard-binary and Standarddecimal arithmetic”.
5. Page 120, 8.8.1.3.1.3, Rounding rules: Change the heading to “Rounding rules
for standard arithmetic”. Add the following introductory paragraph immediately
after the heading:
The ability to specify the rounding rules that apply to standard
intermediate data items is described in 11.8.4a, INTERMEDIATE
ROUNDING clause.
Immediately after that introductory paragraph, add the following heading and text:
8.8.1.3.1.3.1 Rounding rules for INTERMEDIATE ROUNDING IS NEARESTAWAY-FROM-ZERO [Standard Arithmetic: NEAREST-AWAY-FROM-ZERO
phrase of INTERMEDIATE ROUNDING clause]
If INTERMEDIATE ROUNDING IS NEAREST-AWAY-FROM-ZERO is
specified or implied, a standard intermediate data item shall be rounded
to 31 digits in the situations listed below, and the rounding shall occur as
described for the NEAREST-AWAY-FROM-ZERO clause of the
ROUNDED phrase.
6. After that text, duplicate the information from 8.8.1.3.1.3, Rounding rules, starting
after the first paragraph, and including all the numbered elements and the last
paragraph. Delete the note.
7. Immediately thereafter, add the following heading and text:
8.8.1.3.1.2 Rounding rules for INTERMEDIATE ROUNDING IS NEARESTEVEN [Standard Arithmetic: NEAREST-EVEN phrase of
INTERMEDIATE ROUNDING clause]
If INTERMEDIATE ROUNDING IS NEAREST-EVEN is specified, a
standard intermediate data item shall be rounded to 31 digits in the
situations listed below, and the rounding shall occur as described for the
NEAREST-EVEN clause of the ROUNDED phrase.
February 11, 2004
Document Number:
J4/05-0047
Page
8 of 21
8. After that text, duplicate the information from 8.8.1.3.1.3, Rounding rules, starting
after the first paragraph, and including all the numbered elements and the last
paragraph. Delete the note.
9. Immediately thereafter, add the following heading and text:
8.8.1.3.1.3.3 Rounding rules for INTERMEDIATE ROUNDING IS
PROHIBITED
[Standard arithmetic: PROHIBITED phrase of INTERMEDIATE
ROUNDING clause]
If INTERMEDIATE ROUNDING IS PROHIBITED is specified, and the
intermediate value cannot be represented exactly in a standard intermediate data
item, the EC-SIZE-TRUNCATION exception is set to exist and the results of the
operation are undefined.
10. Immediately thereafter, add the following heading:
8.8.1.3.1.3.4 Rounding rules for INTERMEDIATE ROUNDING IS
TRUNCATION [Standard arithmetic: TRUNCATION phrase of
INTERMEDIATE ROUNDING clause]
11. Page 120, 8.8.1.3.1.3.4, Rounding rules for INTERMEDIATE ROUNDING IS
TRUNCATION: Change the first paragraph (which was the original first
paragraph of 8.8.1.3.1, Rounding rules) in part to read “If INTERMEDIATE
ROUNDING IS TRUNCATION is specified or implied, a standard intermediate
data item …”. Delete the note before the last paragraph.
12. Page 122, before 8.8.2, Boolean expressions, add the following:
8.8.1.4 Standard-binary arithmetic [Standard-binary arithmetic]
Standard-binary arithmetic is a method of evaluating an arithmetic expression, an
arithmetic statement, the SUM clause, and certain integer and numeric functions
as specified in 15.3.1, Numeric and integer functions, in a manner consistent with
the rules associated with binary floating-point arithmetic as specified in DRAFT
Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29 20:00.
Standard-binary arithmetic is in effect when the ARITHMETIC IS STANDARDBINARY clause is specified in the OPTIONS paragraph.
The mechanisms for conversion of data items described with a usage of floatshort, float-long, or float-extended into standard binary intermediate data items
February 11, 2004
Document Number:
J4/05-0047
Page
9 of 21
are defined by the implementor [author's note: not by IEEE 754; if float-short
happens to coincide with IEEE 754 Binary32, the implementor needs to say so,
for example].
The EC-DATA-INCOMPATIBLE condition is set to exist when an operand, or a
combination of operands, results in the signaling of an “invalid operation” state as
described in Draft Standard for Floating-Point Arithmetic P754/D0.8.1 – 2004
November 29 20:00 section 7.1, Invalid Operation.
8.8.1.4.1
Standard-binary intermediate data item
[Standard-binary intermediate data item] [Binary128 format]
[FLOAT-BINARY-34 in USAGE clause]
A standard-binary intermediate data item is of the class numeric and the category
numeric. The format of a standard-binary intermediate data item is the same as
for a data item described USAGE FLOAT-BINARY-34. This format is defined in
DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29
20:00 as the Basic 128-bit Binary Format. This format is hereinafter described as
“Binary128 format” for convenience.
When standard-binary arithmetic is in effect, the following rules apply:
1) Any operand of an arithmetic expression that is not already in Binary128
format is converted into this form.
2) The size error is set to exist and the EC-SIZE-OVERFLOW or
EC-SIZE-UNDERFLOW condition is set to exist if the value is too large or too
small, respectively, to be contained in an item in Binary128 format. (See
14.6.4, SIZE ERROR phrase and size error condition).
3) The rounding rules that apply to standard-binary intermediate data items are
described in 11.8.4a, INTERMEDIATE ROUNDING clause.
8.8.1.5 Standard-decimal arithmetic [Standard-decimal arithmetic]
Standard-decimal arithmetic is a method of evaluating an arithmetic expression,
an arithmetic statement, the SUM clause, and certain integer and numeric
functions as specified in 15.3.1, Numeric and integer functions, in a manner
consistent with the rules associated with decimal floating-point arithmetic as
specified in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00. Standard-decimal arithmetic is in effect when the
ARITHMETIC IS STANDARD-DECIMAL clause is specified in the OPTIONS
paragraph.
February 11, 2004
Document Number:
J4/05-0047
Page
10 of 21
The mechanisms for conversion of data items described with a usage of floatshort, float-long, or float-extended into standard decimal intermediate data items
are defined by the implementor [author's note: not by IEEE 754; if float-short
happens to coincide with IEEE 754 Binary32 and the conversion rules from that
format to Decimal128 are those found in IEEE 754, the implementor needs to so
state].
The EC-DATA-INCOMPATIBLE condition is set to exist when an operand, or a
combination of operands, results in the signaling of an “invalid operation” state as
described in Draft Standard for Floating-Point Arithmetic P754/D0.8.1 – 2004
November 29 20:00 section 7.1, Invalid Operation.
8.8.1.5.1 Standard-decimal intermediate data item
[Standard-decimal intermediate data item] [Decimal128]
[FLOAT-DECIMAL-34 in USAGE clause]
A standard-decimal intermediate data item is of the class numeric and the
category numeric. The format of a standard-decimal intermediate data item is
the same as for a data item described USAGE FLOAT-DECIMAL-34, which is
defined in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00 as the Basic 128-bit Decimal Floating Point Encoding
Format. This format is hereinafter described as “Decimal128 format” for
convenience.
When standard-decimal arithmetic is in effect, the following rules apply:
1) Any operand of an arithmetic expression that is not already in Decimal128
format is converted into this form.
2) The size error is set to exist and the EC-SIZE-OVERFLOW or EC-SIZEUNDERFLOW condition is set to exist if the value is too large or too small,
respectively, to be contained in an item in Decimal128 format. Refer to
14.6.4, SIZE ERROR phrase and size error condition, for more information).
3) The rounding rules that apply to standard-decimal intermediate data items
are described in 11.8.4a, INTERMEDIATE ROUNDING clause.
13. Page 184, 11.8.1, OPTIONS paragraph, General format: Add
[intermediate-rounding-clause]
between the two existing entries.
14. Page 184, 11.8.4.1, ARITHMETIC clause. General format:
February 11, 2004
Document Number:
J4/05-0047
Page
11 of 21
[ARITHMETIC clause: STANDARD-BINARY phrase][ARITHMETIC
clause: STANDARD-DECIMAL phrase]
Add STANDARD-BINARY and STANDARD-DECIMAL, underlined, to the list
enclosed in curly braces.
15. Page 184, 11.8.4.2, ARITHMETIC clause, General rules: Add the following new
rules:
2a) If the STANDARD-BINARY phrase is specified, the techniques used in
handling arithmetic expressions, arithmetic statements, the SUM clause, and
integer and numeric functions shall be as described for standard-binary
arithmetic in 8.8.1.4, Standard-binary arithmetic.
2b) If the STANDARD-DECIMAL phrase is specified, the techniques used in
handling arithmetic expressions, arithmetic statements, the SUM clause, and
integer and numeric functions shall be as described for standard-decimal
arithmetic in 8.8.1.5, Standard-decimal arithmetic.
16. Page 184, After all text associated with the ARITHMETIC clause, add the
following new headings and text:
11.8.4a INTERMEDIATE ROUNDING clause
[INTERMEDIATE ROUNDING clause:NEAREST-AWAY-FROM-ZERO
phrase]
[INTERMEDIATE ROUNDING clause: NEAREST-EVEN phrase]
[INTERMEDIATE ROUNDING clause: PROHIBITED phrase]
[INTERMEDIATE ROUNDING clause: TRUNCATION phrase]
The INTERMEDIATE ROUNDING clause specifies the rounding rules that are to
be applied during the production of intermediate results in arithmetic statements
and arithmetic expressions.
11.8.4a.1 General format
INTERMEDIATE ROUNDING
{ IS NEAREST-AWAY-FROM-ZERO
{ [IS NEAREST-EVEN]
{IS PROHIBITED
{IS TRUNCATION
11.8.4a.2 General rules
}
}
}
}
February 11, 2004
Document Number:
J4/05-0047
Page
12 of 21
1) If native arithmetic is in effect, the rounding rules that apply to intermediate
data items are defined by the implementor.
2) If standard arithmetic is in effect, the rounding rules that apply to standard
intermediate data items are specified in 8.8.1.3.1, Rounding rules for
standard arithmetic.
3) If standard-binary arithmetic is in effect:
a. INTERMEDIATE ROUNDING IS NEAREST-AWAY-FROM-ZERO
shall not be specified.
b. If INTERMEDIATE ROUNDING IS NEAREST-EVEN is specified or
implied, the intermediate data item shall be rounded to the nearest
value that can be represented in a Binary128 format in which the
rightmost bit is zero.
c. If INTERMEDIATE ROUNDING IS PROHIBITED is specified and the
intermediate value cannot be represented exactly in a Binary128
format, the EC-SIZE-TRUNCATION exception is set to exist and the
results of the operation are undefined.
d. If INTERMEDIATE ROUNDING IS TRUNCATION is specified and an
intermediate value cannot be exactly represented in a Binary128
format, the value shall be rounded to the nearest value that can be
represented in that format in which the magnitude is smaller than the
intermediate value and in which the rightmost bit of the significand is
zero.
4) If standard-decimal arithmetic is in effect:
a. If INTERMEDIATE ROUNDING IS NEAREST-AWAY-FROM-ZERO is
specified, and an intermediate data item cannot be exactly
represented in a Decimal128 format, the value is rounded to the
nearest value that can be represented in that format. If two such
values are equally near, the value whose magnitude is larger is
chosen.
b. If INTERMEDIATE ROUNDING IS NEAREST-EVEN is specified or
implied, the intermediate data item shall be rounded to the nearest
value that can be represented in a Decimal128 format. If two such
values are equally near, the value in which the rightmost digit of the
significand is even shall be chosen.
c. If INTERMEDIATE ROUNDING IS PROHIBITED is specified and an
intermediate value cannot be exactly represented in a Decimal128
February 11, 2004
Document Number:
J4/05-0047
Page
13 of 21
format, the EC-SIZE-TRUNCATION exception is set to exist and the
results of the operation are undefined.
d. If INTERMEDIATE ROUNDING IS TRUNCATION is specified and an
intermediate data item cannot be exactly represented in a Decimal128
format, the value shall be the nearest value in that format whose
magnitude is not greater than the intermediate value.
17. Page 310, 13.16.38.2, PICTURE clause, syntax rules: Delete Syntax Rule 6.
18. Page 310-312, 16.16.38.2, PICTURE clause, syntax rules: Add the following
rules:
11a. For data items of category numeric, the number of digit positions
described by character-string-1 shall range from 1 through 31.
11b. For floating-point data items of category numeric-edited, the number of
digit positions in the significand portion of character-string-1 shall
range from 1 through 34.
30a. The number of digit positions described by character-string-1 shall
range from 1 through 31.
19. Page 313, 13.16.38.3, PICTURE clause, general rules 12b: Replace the last
paragraph with the following text:
The exponent shall be ‘+9’, ‘+99’, ‘+999’, ‘+9999’, or ‘+9(n)’ where n = 1, 2, 3,
or 4.
20. Page 347, 13.16.51.1, SOURCE clause, General format: Replace “ROUNDED”
in the General format with “rounded-phrase” . Immediately after the general
format, add the following text:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
21. Page 347, 13.16.51.2, SOURCE clause, Syntax rules 2 and 5: Replace “the
ROUNDED phrase” with “rounded-phrase”.
22. Page 347, 13.16.51.2, SOURCE clause, General rule 2: Replace the second
sentence with the following text: “If rounded-phrase is specified, the implicit
COMPUTE statement has the corresponding rounded-phrase.”
February 11, 2004
Document Number:
J4/05-0047
Page
14 of 21
23. Page 347, 13.16.52.1, SUM clause, General format: Replace ROUNDED in the
General format with “rounded-phrase”. Immediately after the general format, add
the following text:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
24. Page 347, 13.16.52.2, SUM clause, General rule 2: Replace the second
sentence with the following text: “If rounded-phrase is specified, the implicit
COMPUTE statement has the corresponding rounded-phrase.”
25. Page 361, 13.16.58.1, USAGE clause, General format:
[FLOAT-BINARY-9 phrase: USAGE clause]
[FLOAT-BINARY16 phrase: USAGE clause]
[FLOAT-BINARY-34 phrase: USAGE clause]
[FLOAT-DECIMAL-7 phrase: USAGE clause]
[FLOAT-DECIMAL-16 phrase: USAGE clause]
[FLOAT-DECIMAL-34 phrase: USAGE clause]
Add the following to the format, all underlined: FLOAT-BINARY-9, FLOATBINARY-16, FLOAT-BINARY-34, FLOAT-DECIMAL-7, FLOAT-DECIMAL-16 and
FLOAT-DECIMAL-34.
26. Page 364, 13.16.58.3, USAGE clause, General rules: Add the following new
rules:
12a) The USAGE FLOAT-BINARY-9 clause specifies that the data item is a
floating-point data item in the format specified for basic 32-bit binary floatingpoint items in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00, Section 3.2, Basic Binary Format Encodings.
12b) The USAGE FLOAT-BINARY-16 clause specifies that the data item is a
floating-point data item in the format specified for basic 64-bit binary floatingpoint items in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00, Section 3.2, Basic Binary Format Encodings.
12c) The USAGE FLOAT-BINARY-34 clause specifies that the data item is a
floating-point data item in the format specified for basic 128-bit binary floatingpoint items in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00, Section 3.2, Basic Binary Format Encodings.
12d) The USAGE FLOAT-DECIMAL-7 clause specifies that the data item is a
floating-point data item in the format specified for basic 32-bit decimal floating-
February 11, 2004
Document Number:
J4/05-0047
Page
15 of 21
point items in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00, Section 3.3, Basic Decimal Format Encodings.
12e) The USAGE FLOAT-DECIMAL-16 clause specifies that the data item is a
floating-point data item in the format specified for basic 64-bit decimal floatingpoint items in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00, Section 3.3, Basic Decimal Format Encodings.
12f) The USAGE FLOAT-DECIMAL-34 clause specifies that the data item is a
floating-point data item in the format specified for basic 128-bit decimal floatingpoint items in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -- 2004
November 29 20:00, Section 3.3, Basic Decimal Format Encodings.
27. Page 399, 14.6.3, ROUNDED phrase: Delete the last sentence of the first
paragraph. Delete index entres for ADD, COMPUTE, DIVIDE, MULTIPLY,
SOURCE, SUBTRACT and SUM.
28. Page 399, 14.6.3, ROUNDED phrase: Add the following new headings and
associated text:
[ROUNDED phrase: AWAY-FROM-ZERO subphrase]
[ROUNDED phrase: NEAREST-AWAY-FROM-ZERO subphrase]
[ROUNDED phrase: NEAREST-EVEN subphrase]
[ROUNDED phrase: NEAREST-TOWARD-ZERO subphrase]
[ROUNDED phrase: PROHIBITED subphrase]
[ROUNDED phrase: TOWARD-GREATER subphrase]
[ROUNDED phrase: TOWARD-LESSER subphrase]
[ROUNDED phrase: TRUNCATION subphrase]
14.6.3.1
General format
ROUNDED [ MODE IS
14.6.3.2
{AWAY-FROM-ZERO
{NEAREST-AWAY-FROM-ZERO
{NEAREST-EVEN
{NEAREST-TOWARD-ZERO
{PROHIBITED
{TOWARD-GREATER
{TOWARD-LESSER
{TRUNCATION
}
}
}
}
}
}
}
}
]
General rules
1) If the MODE subphrase is not specified, execution is as if ROUNDED MODE
IS NEAREST-AWAY-FROM-ZERO had been specified.
February 11, 2004
Document Number:
J4/05-0047
Page
16 of 21
2) If the ROUNDED phrase is not specified, execution is as if ROUNDED MODE
IS TRUNCATION had been specified.
3) If MODE IS AWAY-FROM-ZERO is specified and the arithmetic value cannot
be exactly represented in the resultant identifier, the arithmetic value is
rounded to the nearest value with a larger magnitude that can be represented
in the resultant identifier.
4) If MODE IS NEAREST-AWAY-FROM-ZERO is specified or implied and the
arithmetic value cannot be exactly represented in the resultant identifier, the
arithmetic value is rounded to the nearest value that can be represented in
the resultant identifier. If two such values are equally near, the value whose
magnitude is larger is chosen.
5) If MODE IS NEAREST-EVEN is specified and the arithmetic value cannot be
exactly represented in the resultant identifier, the arithmetic value is rounded
to the nearest value that can be represented in the resultant identifier. If two
such values are equally near, the value whose rightmost digit is even is
chosen.
NOTE This method is sometimes known as “banker’s rounding”.
6) If MODE IS NEAREST-TOWARD-ZERO is specified and the arithmetic value
cannot be exactly represented in the resultant identifier, the arithmetic value
is rounded to the nearest value that can be represented in the resultant
identifier. If two such values are equally near, the value whose magnitude is
smaller is chosen.
7) If MODE IS PROHIBITED is specified, and the arithmetic value cannot be
represented exactly in the resultant identifier, the EC-SIZE-TRUNCATION is
set to exist and the results of the operation are undefined.
8) If MODE IS TOWARD-GREATER is specified, and the arithmetic value
cannot be represented exactly in the resultant identifier, the arithmetic value
is rounded to the nearest larger value that can be represented in the resultant
identifier.
9) If MODE IS TOWARD-LESS is specified, and the arithmetic value cannot be
represented exacty in the resultant identifier, the arithmetic value is rounded
to the nearest smaller value that can be represented in the resultant identifier.
10) If MODE IS TRUNCATION is specified, and the arithmetic value cannot be
represented exactly in the resultant identifier, the arithmetic value is rounded
to the nearest value with a smaller magnitude that can be represented in the
resultant identifier.
February 11, 2004
Document Number:
J4/05-0047
Page
17 of 21
29. Page 402, 14.6.6, Arithmetic statements: Change rule 3 in part to read “When
standard, standard-binary or standard-decimal arithmetic is in effect … “.
30. Page 415, 14.8.2, ADD statement, General format: Replace “ROUNDED” in
General Formats 1 and 3 with “rounded-phrase”. Add the following text
immediately before 14.8.2.2, Syntax rules:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
31. Page 431, 14.8.7.1, COMPUTE statement, General format: Replace
“ROUNDED” in Format 1 with “rounded-phrase”. Add the following text
immediately before 14.8.7.2, Syntax rules:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
32. Page 438-439, 14.8.11.1, DIVIDE statement, General formats: Replace
“ROUNDED” in all five General Formats with “rounded-phrase”. Add the
following text immediately before 14.8.11.2, Syntax rules:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
33. Page 482, 14.8.25.1, MULTIPLY statement, General formats: Replace
ROUNDED in both general formats with “rounded-phrase”. Add the following text
immediately before 14.8.25.2, Syntax rules:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
34. Page 539, 14.8.40.1, SUBTRACT statement, General formats: Replace
ROUNDED in all three general formats with “rounded-phrase”. Add the following
text immediately before 14.8.40.2, Syntax rules:
where rounded-phrase is described in 14.6.3, ROUNDED phrase.
35. Page 565, 15.3.1, Numeric and integer functions: Replace all instances of the
phrase “standard arithmetic” with “standard arithmetic, standard-binary
arithmetic, or standard-decimal arithmetic”.
36. Page 566, 15.3.1, Numeric and integer functions, last paragraph: Replace in part
“When either standard or native arithmetic is in effect …” with “When either
February 11, 2004
Document Number:
J4/05-0047
Page
18 of 21
standard arithmetic, standard-binary arithmetic, standard-decimal arithmetic, or
native arithmetic is in effect …”
37. Page 588, 15.22.2, E function, Returned values: Replace all text with the
following:
1) If native arithmetic is in effect, the returned value is an implementor-defined
approximation of the arithmetic expression
(2 + 0.7182818284590452353602874713526).
2) If standard arithmetic is in effect, the equivalent arithmetic expression is
(2 + 0.7182818284590452353602974713526)
3) If standard-binary arithmetic is in effect, the returned value is the exact value
of the arithmetic expression
(14,114,126,198,520,207,781,233,383,725,636,853 / (2 ** 112))
in Binary128 format, normalized as described in DRAFT Standard for
Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29 20:00.
4) If standard-decimal arithmetic is in effect, the equivalent arithmetic
expression is the exact value of the arithmetic expression
(2.718281828459045235360287471352662)
in Decimal128 format, normalized as described in DRAFT Standard for
Floating-Point Arithmetic P754/D0.8.1 – 2004 November 29 20:00.
38. Page 623, 15.56.2, NUMVAL-F function, Argument rule 1: Change in part to
read “ … n is one, two, three, or four digits representing … digit is a string of 1 to
34 digits.”
39. Page 623, 15.56.2, NUMVAL-F function, Argument rule 2: Change in part to
read “If standard arithmetic or native arithmetic is in effect, the total number …”
40. Page 623, 15.56.2, NUMVAL-F function: Add a new Argument rule as follows:
2a. If standard-binary or standard-decimal arithmetic is in effect, the total
number of digits in the significand shall not exceed 34.
February 11, 2004
Document Number:
J4/05-0047
Page
19 of 21
41. Page 623, 15.56.3, NUMVAL-F function, Returned values: Change the second
sentence of rule 2 in part to read “If standard arithmetic, standard-binary
arithmetic, or standard-decimal arithmetic is in effect …”.
42. Page 627, 15.60.2, PI function, Returned values: Replace all text with the
following:
1) If native arithmetic is in effect, the returned value is an implementor-defined
approximation of the arithmetic expression
(3 + 0.1415926535897932384626433832795).
.
2) If standard arithmetic is in effect, the equivalent arithmetic expression is
(3 + 0.14159265358979323846264338372950).
3) If standard-binary arithmetic is in effect, the returned value is the exact value
of the arithmetic expression
(16,312,081,666,030,376,401,667,486,162,748,272 / (2 ** 112))
in Binary128 format, normalized as described in DRAFT Standard for
Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29 20:00.
4) If standard-decimal arithmetic is in effect, the returned value is exactly
3.141592653589793238462643383729503
in Decimal128 format, normalized as described in DRAFT Standard for
Floating-Point Arithmetic P754/d0.8.1 – 2004 November 29 20:00.
43. Page 635, 15.68.3, SQRT function, Returned values: Change Rule 1 in part to
read “When standard arithmetic, standard-binary arithmetic, or standard-decimal
arithmetic is in effect …”.
44. Page 635, 15.68.3, SQRT function, Returned values: Add the following two rules
after Rule 2:
2a) When standard-decimal arithmetic is in effect, the returned value is the
absolute value of the exact square root of argument-1 rounded to 34 digits
February 11, 2004
Document Number:
J4/05-0047
Page
20 of 21
according to the rules for standard-decimal arithmetic and stored in a
standard-decimal intermediate data item.
2b) When standard-binary arithmetic is in effect, the returned value is the
absolute value of the exact square root of argument-1 rounded to 113
significant bits in the significand according to the rules for standard-binary
arithmetic and stored in a standard-binary intermediate data item.
45. Page 644, 15.77.3, TEST-NUMVAL-F function, Returned value rules:
Change Note 2 in part to read “If either standard arithmetic or native arithmetic is
in effect, because the character …”
Replcate all of NOTE 2 as new NOTE 3, and change in part to read “If either
standard-binary or standard-decimal arithmetic is in effect, because the character
… 35th digit … 35th digit …”
46. Page 670, A.3, Processor-dependent language element list: Add the following
entries:
2a) The ability to specify a significand longer than 31 digits in a floating-point
literal is a processor-dependent element of standard COBOL.
2b) The availability of the ARITHMETIC IS STANDARD-BINARY and
ARITHMETIC IS STANDARD-DECIMAL clauses of the OPTIONS paragraph
is dependent on the capabilities of the processor.
2c) The availability of the NEAREST-EVEN and PROHIBITED phrases of the
INTERMEDIATE ROUNDING clause of the OPTIONS paragraph is
dependent on the capabilities of the processor.
2d) The availability of the NEAREST-EVEN, NEAREST-AWAY-FROM-ZERO,
NEAREST-TOWARD-ZERO, PROHIBITED, TOWARD-GREATER and
TOWARD-LESSER subphrases of the ROUNDED phrase is dependent on
the capabilities of the processor.
5a) The usages FLOAT-BINARY-9, FLOAT-BINARY-16, and FLOAT-BINARY-34
are dependent on the availability of a suitable computer architecture for the
basic binary floating-point formats Binary32, Binary64 and Binary128 as
described in DRAFT Standard for Floating-Point Arithmetic P754/D0.8.1 -2004 November 29 20:00.
5b) The usages FLOAT-DECIMAL-7, FLOAT-DECIMAL-16 and FLOATDECIMAL-34 are dependent on the availability of a suitable computer
architecture for the basic decimal floating-point formats Decimal32,
February 11, 2004
Document Number:
J4/05-0047
Page
Decimal64 and Decimal128 formats as described in DRAFT Standard for
Floating-Point Arithmetic P754/D0.8.1 -- 2004 November 29 20:00.
21 of 21
Download