This chapter is concerned with parameters which characterise certain aspects of the computing environment in which the NAG Library is implemented. They relate primarily to floating-point arithmetic, but also to integer arithmetic, the elementary functions and exception handling. The values of the parameters vary from one implementation of the Library to another, but within the context of a single implementation they are constants.
The parameters are intended for use primarily by other functions in the Library, but users of the Library may sometimes need to refer to them directly.
These parameters are implemented as functions which are made available via macros, using upper case names, defined in the header file <nagx02.h>. For example, the macro X02AJC is defined as a call to function x02ajc().
2Background to the Problems
2.1.1A model of floating-point arithmetic
In order to characterise the important properties of floating-point arithmetic by means of a small number of parameters, NAG uses a simplified model of floating-point arithmetic. The parameters of the model can be chosen to provide a sufficiently close description of the behaviour of actual implementations of floating-point arithmetic, but not, in general, an exact description; actual implementations vary too much in the details of how numbers are represented or arithmetic operations are performed.
The model is based on that developed by Brown (1981), but differs in some respects. The essential features are summarised here.
The model is characterised by four integer parameters. The four integer parameters are:
the precision (i.e., the number of significant base- digits)
the minimum exponent
the maximum exponent
These parameters define a set of numerical values of the form:
where the exponent must lie in the range , and the fraction (also called the mantissa or significand) lies in the range
, and may be written
Thus is a -digit fraction to the base ; the are the base- digits of the fraction: they are integers in the range to , and the leading digit must not be zero.
The set of values so defined (together with zero) are called model numbers. For example, if , , and , then a typical model number is .
The model numbers must obey certain rules for the computed results of the following basic arithmetic operations: addition, subtraction, multiplication, negation, absolute value, and comparisons: the computed result must be the nearest model number to the exact result (assuming that overflow or underflow does not occur); if the exact result is midway between two model numbers, then it may be rounded either way.
For division and square root, this latter rule is relaxed: the computed result may also be one of the next adjacent model numbers on either side of the permitted values just stated.
On many machines, the full set of representable floating-point numbers conforms to the rules of the model with appropriate values of , , and . For machines supporting IEEE binary double precision arithmetic:
(Note: the model used here differs from that described in Brown (1981) in the following respect: square-root is treated, like division, as a weakly supported operator.)
2.1.2Derived parameters of floating-point arithmetic
Most numerical algorithms require access, not to the basic parameters of the model, but to certain derived values, of which the most important are:
the machine precision :
the smallest positive model number:
the largest positive model number:
It is important to note that the machine precision defined here differs from that defined by ISO Fortran 95 (1997).
Two additional derived values are used in the NAG Library. Their definitions depend not only on the properties of the basic arithmetic operations just considered, but also on properties of some of the elementary functions. We define the safe range parameter to be the smallest positive model number such that for any in the range the following can be computed without undue loss of accuracy, overflow, underflow or other error:
In a similar fashion we define the safe range parameter for complex arithmetic as the smallest positive model number such that for any in the range  the following can be computed without any undue loss of accuracy, overflow, underflow or other error:
where is any of , , , , , , and is the square root of .
2.2Other Aspects of the Computing Environment
No attempt has been made to characterise comprehensively any other aspects of the computing environment. The other functions in this chapter provide specific information that is occasionally required by functions in the Library.
3Recommendations on Choice and Use of Available Functions
Derived parameters of model of floating-point arithmetic,