Information technology — Language independent arithmetic — Part 1: Integer and floating point arithmetic

Defines integer and floating point data types (bounded, unbounded, and modulo integer types as well as normalized and denormalized floating point types) on computer systems and their properties to ensure that the processing of arithmetic data can be undertaken in a reliable and predictable manner. The requirements given shall be in addition to those that may be specified in other standards, e.g. those for programming languages.

Technologies de l'information — Arithmétique indépendante de langage — Partie 1: Arithmétique de nombres entiers et en virgule flottante

General Information

Status
Withdrawn
Publication Date
21-Dec-1994
Withdrawal Date
21-Dec-1994
Current Stage
9599 - Withdrawal of International Standard
Completion Date
11-Jul-2012
Ref Project

Buy Standard

Standard
ISO/IEC 10967-1:1994 - Information technology -- Language independent arithmetic
English language
92 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (Sample)

INTERNATIONAL
ISO/IEC
STANDARD
10967-1
First edition
1994-12-15
Information technology - Language
independent arithmetic -
Part 1:
Integer and floating Point arithmetic
Technologies de I ’informa tion - Arithm6 tique independan te de
langage -
Partie 1: Arithmktique de nombres en tiers et en virgule flottante
Reference number
ISO/1 EC 10967-1: 1994(E)

---------------------- Page: 1 ----------------------
ISO/IEC 1096791:1994(E)
Contents
1
1 Scope
................. 1
1.1 Specifications included in this part of ISO/IEC 10967
2
...........
1.2 Specifications not within the scope of this part of ISO/IEC 10967
3
2 Conformity
3
3 Normative reference
4
4 Symbols and definitions
4
...........................................
4.1 Symbols
4
..........................................
4.2 Definitions
6
5 The arithmetic types
........................................ 7
5.1 Integer types
8
.....................................
5.1.1 Operations
.......................... 8
5.1.2 Modul0 integers versus Overflow
9
.......................................
5.1.3 Axioms
.................................... 10
5.2 Floating Point types
11
.........................
5.2.1 Range and granularity constants
11
.....................................
5.2.2 Operations
.............................. 12
5.2.3 Approximate operations
12
...............................
5.2.4 Approximate addition
...................................... 13
5.2.5 Rounding
13
...................................
5.2.6 Result function
14
.......................................
5.2.7 Axioms
................................ 15
5.2.8 Rounding constants
16
..............................
5.2.9 Conformity to IEC 559
................................... 16
5.3 Conversion operations
18
6 Not ificat ion
.................................. 18
6.1 Notification alternatives
........................... 18
6.1.1 Language defined notification
19
..............................
6.1.2 Recording of indicators
............................. 20
6.1.3 Termination with message
20
....................................
6.2 Delays in notification
....................... 21
6.3 User selection of alternative for notification
21
7 Relationship wit h language Standards
22
8 Documentation requirements
0 ISO/IEC 1994
All rights reserved. Unless otherwise specified, no part of this publication may be
reproduced or utilized in any form or by any means, electronie or mechanical, including
photocopying and microfilm, without Permission in writing from the publisher.
ISO/IEC Copyright Office l Case postale 56 l CH-121 1 Geneve 20 l Switzerland
Printed in Switzerland
ii

---------------------- Page: 2 ----------------------
@ ISO/IEC ISO/IEC 10967~1:1994(E)
Annexes
A Rat ionale 24
A.1 Scope
............................................ 24
A.1.1 Specifications included in this part of ISO/IEC 10967 . 24
Al.2 Specifications not within the scope of this part of ISO/IEC 10967. . 24
Al.3 Proposed follow-ons to this part of ISO/IEC 10967 25
...............
A.2 Conformity 25
.........................................
A.2.1 Validation
...................................... 26
A.3 Normative references
.................................... 26
A.4 Symbols and definitions . ; . 26
A.4.1 Symbols
....................................... 27
A.4.2 Definitions 27
.....................................
A.5 The arithmetic types
.................................... 28
A.5.1 Integer types 28
....................................
A.5.1.1
Operations . 30
A.5.1.2 Modul0 integers versus Overflow 30
....................
A.5.1.3 Axioms . 30
A.5.2 Floating Point types 31
................................
A.5.2.1 Range and granularity constants . 35
A.5.2.2 Operations 36
................................
A.5.2.3 Approximate operations . 37
A.5.2.4 Approximate addition 37
..........................
A.5.2.5 Rounding . 39
A.5.2.6 Result function 39
..............................
A.5.2.7 Axioms . 40
A.5.2.8 Rounding constants . 40
A.5.2.9 Conformity to IEC 559 . 41
A.5.2.10 Relations among floating Point types 41
.................
A.5.2.11 Levels of predictability . 41
A.5.2.12 Identities 42
.................................
A.5.2.13 Precision, accuracy, and error . 44
A.5.2.14 Extra precision
.............................. 47
A.5.3 Conversion operations 48
...............................
A.6 Notification
......................................... 48
A.6.1 Notification alternatives . 48
A.6.1.1 Language defined notification . 49
A.6.1.2 Recording of indicators 49
.........................
A.6.1.3 Termination with message
....................... 50
A.6.2 Delays in notification 50
................................
A.6.3 User selection of alternative for notification . 51
A.7 Relationship with language Standards
.......................... 51
A.8 Documentation requirements .
52
B Partial conformity 54
C IEC 559 bindings 55
C.l Summary . 55
C.2 Notification 56
.........................................
C.3 Rounding . 56
. . .
111

---------------------- Page: 3 ----------------------
@ ISO/IEC
ISO/IEC 10967-1:1994(E)
57
D Requirements beyond IEC 559
58
E Bindings for specific languages
58
.....................................
El . General comments
59
E2 . Ad a .
62
E3 . BASIC .
64
E4 . C .
67
E5 . Common Lisp .
70
. Fortran
E6 .
73
E7 . Modula-2 .
................................ 73
E8 . Pascal and Extended Pascal
76
. PL/1 .
E9
79
F Example of a conformity Statement
79
F.l Types .
79
F.2 Integer Parameters .
80
.................................
F.3 Floating Point Parameters
80
F.4 Definitions .
81
F.5 Expressions .
81
F.6 Notification .
82
G Example programs
82
..............................
G.l Verifying platform acceptability
82
..................................
G.2 Selecting alternate code
83
G.3 Terminating a loop .
83
G.4 Fast versus reliable .
83
..................................
G.5 High-precision multiply
84
......................................
G.6 Estimating error
84
..............................
G.7 Saving and restoring indicators
86
H Bibliography
89
J Glossary

---------------------- Page: 4 ----------------------
@ ISO/IEC ISO/IEC 10967=1:1994(E)
Foreword
ISO (the International Organization for Standardization) and IEC (the Inter-
national 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. Draft International Standards adopted by the
joint technical committee are circulated to national bodies for voting. Publication
as an International Standard requires approval by at least 75 % of the national
bodies casting a vote.
International Standard ISO/IEC 10967-1 was prepared by Joint Technical Com-
mi ttee ISO/IEC JTC 1, Information technology, Subcommittee SC 22,
Programming languages, their environments and System soj?ware interfaces.
ISO/IEC 10967 consists of the following Parts, under the general title Znformation
technology - Language independent arithmetic:
- Part 1: Integer andfloating Point arithmetic
- Part 2: Mathematical procedures
- Part 3: Complex arithmetic and procedures
Additional Parts will specify other arithmetic types or operations.
Annexes A to J of this part of ISO/IEC 10967 are for information only.

---------------------- Page: 5 ----------------------
@ ISO/IEC
ISO/IEC 10967=1:1994(E)
Introduction
The aims
Programmers writing programs that perform a significant amount of numeric processing have often
not been certain how a program will perform when run under a given language processor. Program-
ming language Standards have traditionally been somewhat weak in the area of numeric processing,
seldom providing an adequate specification of the properties of arithmetic data types, particularly
floating Point numbers. Often they do not even require much in the way of documentation of the
actual arithmetic data types by a conforming language processor.
It is the intent of this part of ISO/IEC 10967 to help to redress these shortcomings, by setting out
precise definitions of integer and floating Point data types, and requirements for documentation.
This is done in a way that makes as few presumptions as possible about the underlying machine
architecture.
It is not claimed that this part of ISO/IEC 10967 will ensure complete certainty of arithmetic
behavior in all circumstances; the complexity of numeric Software and the difficulties of analysing
and proving algorithms are too great for that to be attempted. Rather, the requirements set forth
here will provide a firmer basis than hitherto for attempting such analysis.
Hence the first aim of this part of ISO/IEC 10967 is to enhance the predictability and reliability
of the behavior of programs performing numeric processing.
The second aim, which helps to support the first, is to help programming language Standards to
express the semantics of arithmetic data types. These semantics need to be precise enough for
numerical analysis, but not so restrictive as to prevent efficient implementation of the language on
a wide range of platforms.
The third aim is to help enhance the portability of programs that perform numeric processing
across a range of different platforms. Improved predictability of behavior will aid programmers
designing code intended to run on multiple platforms, and will help in predicting what will happen
when such a program is moved from one conforming language processor to another.
Note that this part of ISO/IEC 10967 does not attempt to ensure bit-for-bit identical results
when programs are transferred between language processors, or translated from one language into
another. Programming languages and platforms are too diverse to make that a sensible goal. How-
ever, experience Shows that diverse numeric environments tan yield comparable results under most
circumstances, and that with careful program design significant portability is actually achievable.
The content
This part of ISO/IEC 10967 defines the fundamental properties of integer and floating Point num-
bers. These properties are presented in terms of a parameterized model. The Parameters allow
enough Variation in the model so that most platforms are covered, but when a particular set of
Parameter values is selected, and all required documentation is supplied, the resulting information
should be precise enough to permit careful numerical analysis.
The requirements of this part of ISO/IEC 10967 cover three areas. First, the programmer must
be given runtime access to the Parameters and functions that describe the arithmetic properties
of the platform. Second, the executing program must be notified when proper results cannot be
returned (e.g., when a computed result is out of range or undefined). Third, the numeric properties
of conforming platforms must be publicly documented.
vi

---------------------- Page: 6 ----------------------
ISO/IEC 10967=1:1994(E)
@ ISO/IEC
This part of ISO/IEC 10967 focuses on the classical integer and floating Point data types. Later
Parts will consider common mathematical procedures (Part 2), complex numbers (Part 3), and
possibly additional arithmetic types such as fixed Point.
Relations hip to hardware
ISO/IEC 10967 is not a hardware architecture Standard. It makes no sense to talk about an “LIA
machine.” Future platforms are expected either to duplicate existing architectures, or to satisfy
high quality architecture Standards such as IEC 559 (also known as IEEE 754). The floating Point
requirements of this part of ISO/IEC 10967 are compatible with (and enhance) IEC 559.
This part of ISO/IEC 10967 provides a bridge between the abstract view provided by a programming
language Standard and the precise details of the actual arithmetic implementation.
The benefits
Adoption and proper use of this part of ISO/IEC 10967 tan lead to the following benefits.
Language Standards will be able to define their arithmetic semantics more precisely without pre-
venting the efficient implementation of their language on a wide range of machine architectures.
Programmers of numeric Software will be able to assess the portability of their programs in advance.
Programmers will be able to trade off program design requirements for portability in the resulting
program.
Programs will be able to determine (at run time) the crucial numeric properties of the implementa-
tion. They will be able to reject unsuitable implernentations, and (possibly) to correctly characterize
the accuracy of their own results. Programs will be able to extract apparently implementation de-
pendent data (such as the exponent of a floating Point number) in an implementation independent
way. Programs will be able to detect (and possibly correct for) exceptions in arithmetic processing.
End users will find it easier to determine whether a (properly documented) application program is
likely to execute satisfactorily on their platform. This tan be done by comparing the documented
requirements of the program against the documented properties of the platform.
Finally, end users of numeric application packages will be able to rely on the correct execution of
those packages. That is, for correctly programmed algorithms, the results are reliable if and only
if there is no notification.
vii

---------------------- Page: 7 ----------------------
ISO/IEC 10967=1:1994(E) @ ISO/IEC
Annex A is intended to be read in parallel with the Standard.
. . .
Vlll

---------------------- Page: 8 ----------------------
INTERNATIONAL STANDARD 0 ISO/IEC
ISOiIEC 10967-1: 1994(E)
Information technology -
Language independent arit hmetic -
Part 1:
Integer and floating Point arithmetic
1 Scope
This part of ISO/IEC 10967 defines the properties of integer and floating Point data types on com-
Puter Systems to ensure that the processing of arithmetic data tan be undertaken in a reliable and
predictable manner. Emphasis is placed on documenting the existing Variation between Systems,
not on the elimination of such Variation. The requirements of this part of ISO/IEC 10967 shall
be in addition to those that may be specified in other Standards, such as those for programming
languages (See clause 7).
It is not the purpose of this part of ISO/IEC 10967 to ensure that an arbitrary numerical function
tan be so encoded as to produce acceptable results on all conforming Systems. Rather, the goal
is to ensure that the properties of arithmetic on a conforming System are made available to the
programmer.
Therefore, it is not reasonable to demand that a Substantive piece of Software run on every imple-
mentation that tan Claim conformity to this part of ISO/IEC 10967.
An implernentor may choose any combination of hardware and Software support to meet the speci-
fications of this part of ISO/IEC 10967. It is the arithmetic environment, as seen by the User, that
does or does not conform to the specifications.
The term implementation (of this part of ISO/IEC 10967) d enotes the total arithmetic environment,
including hardware, language processors, exception handling facilities, subroutine libraries, other
Software, and all pertinent documentation.
1.1 Specifications included in this part of ISO/IEC 10967
This part of ISO/IEC 10967 defines integer and floating Point data types. Definitions are included
for bounded, unbounded, and modulo integer types, as well as both normalized and denormalized
floating Point types.
The specification for an arithmetic type includes
a) The set of computable values.
b) The set of computational operations provided, including
1) primitive operations (addition, subtraction, etc.) with operands of the Same type,

---------------------- Page: 9 ----------------------
@ ISO/IEC
ISO/IEC 10967=1:1994(E)
2) comparison operations on two operands of the Same type,
3) conversion operations from any arithmetic type to any other arithmetic type, and
4) operations that access properties of individual values.
c) Program-visible Parameters that characterize the values and operations.
d) Procedures for reporting arithmetic exceptions.
NOTE - A.1.3 describes planned future work in this area.
1.2 Specifications not within the scope of this part of ISO/IEC 10967
This part of ISO/IEC 10967 provides no specifications for
a) Arithmetic and comparison operations whose operands are of more than one data type. This
part of ISO/IEC 10967 neither requires nor excludes the presence of such “mixed Operand”
operations.
b) A general unnormalized floating Point data type, or the operations on such data. This part .
of ISO/IEC 10967 neither requires nor excludes such data or operations.
This part of ISO/IEC 10967 neither
c) An interval data type, or the operations on such data.
requires nor excludes such data or operations.
d) A fixed Point data type, or the operations an such data. This part of ISO/IEC 10967 neither
requires nor excludes such data or operations.
e) A rational data type, or the operations on such data. This part of ISO/IEC 10967 neither
requires nor excludes such data or operations.
f) The properties of arithmetic data types that are not related to the numerical process, such
as the representation of values on physical media.
g) Floating Point values that represent infinity or non-numeric results. However, specifications
for such values are given in IEC 559.
h) The properties of integer and floating Point data types that properly belong in language
Standards. Examples include
1) The Syntax of literals and expressions.
2) The precedence of Operators.
3) The rules of assignment and Parameter passing.
4) The presence or absence of automatic type coercions.
5) The consequences of applying an Operation to values of improper type, or to uninitialized
data.
NOTE - See clause 7 and annex E for a discussion of language Standards and language
bindings.
The internal representation of values is beyond the scope of this part of ISO/IEC 10967. Internal
representations need not be unique, nor is there a requirement for identifiable fields (for sign,
exponent, and so on). The value of the exponent bias, if any, is not specified.

---------------------- Page: 10 ----------------------
@ ISO/IEC ISO/IEC 1096701:1994(E)
2 Conformity
It is expected that the provisions of this part of ISO/IEC 10967 will be incorporated by reference
and further defined in other International Standards; specifically in language Standards and in
language binding Standards. Binding Standards specify the correspondence between the abstract
data types and operations of this part of ISO/IEC 10967 and the concrete language Syntax of the
language Standard. A language Standard that explicitly provides such binding information tan
serve as a binding Standard.
When a binding Standard for a language exists, an implementation shall be said to conform to this
part of ISO/IEC 10967 if and only if it conforms to the binding Standard. In particular, in the case
of conflict between a binding Standard and this part of ISO/IEC 10967, the specifications of the
binding Standard shall take precedence.
When no binding Standard for a ianguage exists, an implementation conforms to this part of
ISO, ‘IEC 10967 ‘1 f and only if it provides one or more data types that together satisfy all the
requirements of clauses 5 through 8. Conformity is relative to that designated set of data types.
NOTES
Language bindings are essential. Clause 8 requires an implementation to supply a binding if
1
no binding Standard exists. See clause A.7 for recommendations on the proper content of a
binding Standard. See annex F for an example of a conformity Statement, and annex E for
suggested language bindings.
2 A complete binding for this part of ISO/IEC 10967 will include a binding for IEC 559 as
well. See 5.2.9 and annex C.
An implementation is free to provide arithmetic types that do not conform to this part of ISO/IEC
10967 or that arc beyond the scope of this part of ISO/IEC 10967. The implementation shall not
Claim conformity for such types.
An implementation is permitted to have modes of Operation that do not conform to this part of
ISO/IEC 10967. However, a conforming implementation shall specify how to select the modes of
Operation that ensure conformity.
3 Normative reference
The following Standard contains provisions which, through reference in this text, constitute provi-
sions of this part of ISO/IEC 10967. At the time of publication, the edition indicated was valid.
and Parties to agreements based on this part of ISO/IEC
All Standards are subject to revision,
10967 are encouraged to investigate the possibility of applying the most recent edition of the stan-
dard indicated below. Members of IEC and ISO maintain registers of currently valid International
Standards.
IEC 559:1989, Binary fioating-Point arithmetic for microprocessor Systems.

---------------------- Page: 11 ----------------------
ISO/IEC 10967=1:1994(E)
@ ISO/IEC
4 Symbols and definitions
4.1 Symbols
In this part of ISO/IEC 10967, Z denotes the set of mathematical integers, R denotes the set of
real numbers, and C denotes the set of complex numbers. Note that Z c R c C.
All prefix and infix Operators have their conventional (exact) mathematical mean.ing. The conven-
tional notation for set definition and manipulation is also used. In particular this part of ISO/IEC
10967 uses
3 and C-J for logical implication and equivalence
-
*, /, xy, Zog,y, fi, 1x1, 1x1, and tr(x) on reals
+
<: 5: =, #, >, and > on reals
-
on sets of integers and reals
X, U, E, C, and =
max and min on non-empty sets of integers and reals
-+ for a mapping between sets
This part of ISO/IEC 10967 uses * for multiplication, and x for the Cartesian product of Sets.
For x E R, the notation 1x1 designates the largest integer not greater than x:
and x-l 1x1 E z
and tr(x) designates the integer part of x (truncated toward 0):
tr(x) = 1x1 ifx>O
=-l-x] ifx70
The type Boolean consists of the two values true and false. Predicates (like < and =) produce
values of type Boolean.
4.2 Definitions
For the purposes of this part of ISO/IEC 10967, the following definitions apply:
arithmetic data type: A data type whose values are members of Z, R, or C.
NOTE 1 - This part of ISO/IEC 10967 specifies requirements for integer and floating Point
data types. Complex numbers are not covered here, but will be included in a subsequent
part of ISO/IEC 10967 [15].
axiom: A general rule satisfied by an Operation and all values of the data type to which the
Operation belongs. As used in the specifications of operations, axioms are requirements.
continuation value: A computational value used as the result of an arithmetic Operation when
an exception occurs. Continuation values are intended to be used in subsequent arithmetic
processing. (Contrast with exceptional value. See 6.1.2.)
- The infinities and NaNs produced by an IEC 559 System are examples of
NOTE 2
continuation values.
data type: A set of values and a set of operations that manipulate those values.
denormalization 10s~: A larger than normal rounding error caused by the fact that denormalized
values have less than full precision. (See 5.2.5 for a full definition.)

---------------------- Page: 12 ----------------------
@ ISO/IEC ISO/IEC 10967=1:1994(E)
denormalized: Those values of a floating Point type F that provide less than the full precision
allowed by that type. (See FD in 5.2 for a full definition.)
error: (1) The differente between a computed value and the correct value. (Used in phrases like
“rounding error” or “error bound. “)
(2) A synonym for exception in phrases like “error message” or “error output.” Error and
exception are not Synonyms in any other context.
exception: The inability of an Operation to return a suitable numeric result. This might arise
because no such result exists mathematically, or because the mathematical result cannot be
represented with sufficient accuracy.
exceptional value: A non-numeric value produced by an arithmetic Operation to indicate the oc-
currence of an exception. Exceptional values are not used in subsequent arithmetic processing.
(See clause 5.)
NOTES
3 Exceptional values are used as part of the defining formalism only. With respect to this
part of ISO/IEC 10967, they do not represent values of any of the data types described.
There is no requirement that they be represented or stored in the computing System.
4 Exceptional values are not to be confused with the NaNs and infinities defined in IEC
559. Contrast this definition with that of contirazscatiora uarke above.
exponent bias: A number added to the exponent of a floating Point number, usually to transform
the exponent to an unsigned integer.
helper function: A function used solely to aid in the expression of a requirement. Helper functions
are not visible to the programmer, and are not required to be part of an implementation.
However, some implementation defined helper functions are required to be documented.
implementation (of this part of ISO/IEC 10967): The total arithmetic environment presented to
a programmer, including hardware, language processors, exception handling facilities, sub-
routine libraries, other Software, and all pertinent documentation.
normalized: Those values of a floating Point type F that provide the full precision allowed by
that type. (See 8 ’~ in 5.2 for a full definition.)
notification: The process by which a program (or that program ’s User) is informed that an arith-
metic exception has occurred. For example, dividing 2 by 0 results in a notification. (See
clause 6 for details.)
Operation: A function directly available to the User, as opposed to helper functions or theoretical
mathematical functions.
precision: The number of digits in the fraction of a floating Point number. (See 5.2.)
rounding: The act of computing a representable final result for an Operation that is close to the
exact (but unrepresentable) result for that Operation. Note that a suitable representable
result may not exist (see 5.2.6). (S ee also A.5.2.5 for some examples.)
rounding function: Any function rnd : R -+ X (where X is a discrete subset of R) that maps
each element of X to itself, and is monotonic non-decreasing. Formally, if x and y arc in R,
x E X + rnd(x) = x
x < y 3 rd(x) 5 rnd(y)
5

---------------------- Page: 13 ----------------------
@ ISO/IEC
ISO/IEC 10967=1:1994(E)
Note that if u E R is between two adjacent values in X, r&(u) selects one of those adjacent
values.
round to nearest: The property of a rounding function r& that when u E 73 is between two
adjacent values in X, rnd(u) selects the one nearest u. If the adjacent values are equidistant
from u, either may be Chosen.
round toward minus infinity: The property of a rounding function rnd that when u E R is
between two adjacent values in X, rnd(u) selects the one less than u.
round toward Zero: The property of a rounding function rnd that when u E R is between two
adjacent values in X, rnd(u) selects the one nearest 0.
shall: A verbal form used to indicate requirements strictly to be followed in Order to conform to
the Standard and from which no deviation is permitted. (Quoted from [2].)
should: A verbal form used to indicate that among several possibilities one is recommended as
particularly suitable, without mentioning or excluding others; or that (in the negative form)
a certain possibility is deprecated but not prohibited. (Quoted from [2].)
signature (of a function or Operation): A summary of information about an Operation or function.
A signature includes the Operation name, the minimum set of inputs to the Operation, and
the maximum set of Outputs from the Operation (including exceptional values if any). The
signature
addi : I x I -+ I U {integer-Overflow}
states that the Operation named addi shall accept any pair of I values as input, and (when
given such input) shall return either a Single I value as its output or the exceptional value
integer-Overflow.
A signature for an Operation or function does not
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.