hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox Chapter Introduction

X02 — Machine Constants

Scope of the Chapter

This chapter is concerned with parameters which characterise certain aspects of the computing environment in which the NAG Toolbox 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.

Background to the Problems

Floating-point Arithmetic

A 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:
bb: the base
pp: the precision (i.e., the number of significant base-bb digits)
eminemin: the minimum exponent
emaxemax: the maximum exponent
These parameters define a set of numerical values of the form:
f × be
f×be
where the exponent ee must lie in the range [emin,emaxemin,emax], and the fraction ff (also called the mantissa or significand) lies in the range [ 1 / b ,1) [ 1 / b ,1) , and may be written
f = 0 . f1f2fp
f=0. f1f2fp
Thus ff is a pp-digit fraction to the base bb; the fifi are the base-bb digits of the fraction: they are integers in the range 00 to b1b-1, and the leading digit f1f1 must not be zero.
The set of values so defined (together with zero) are called model numbers. For example, if b = 10b=10, p = 5p=5, emin = 99emin=-99 and emax = + 99emax=+99, then a typical model number is 0.12345 × 10670.12345×1067.
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 bb, pp, eminemin and emaxemax. For machines supporting IEEE binary double precision arithmetic:
b = 2
p = 53
emin = 1021
emax = 1024.
b = 2 p = 53 emin = -1021 emax = 1024.
(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.)

Derived 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 εε: = ((1/2)) × b1p=(12) ×b1-p
  the smallest positive model number: = bemin1=bemin-1
  the largest positive model number: = (1bp) × bemax=(1-b-p)×bemax
It is important to note that the machine precision defined here differs from that defined by ISO (1997).
Two additional derived values are used in the NAG Toolbox. 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 zz such that for any xx in the range [z,1 / z][z,1/z] 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 zz such that for any xx in the range [z,1 / zz,1/z] the following can be computed without any undue loss of accuracy, overflow, underflow or other error: where ww is any of xx, ixix, x + ixx+ix, 1 / x1/x, i / xi/x, 1 / x + i / x1/x+i/x, and ii is the square root of 1-1
This parameter was introduced to take account of the quality of complex arithmetic on the machine. On machines with well implemented complex arithmetic, its value will differ from that of the real safe range parameter by a small multiplying factor less than 1010. For poorly implemented complex arithmetic this factor may be larger by many orders of magnitude.

Other 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.

Recommendations on Choice and Use of Available Functions

Derived parameters of model of floating point arithmetic, 
    largest positive model number nag_machine_real_largest (x02al)
    machine precision nag_machine_precision (x02aj)
    safe range nag_machine_real_safe (x02am)
    safe range of complex floating point arithmetic nag_machine_complex_safe (x02an)
    smallest positive model number nag_machine_real_smallest (x02ak)
Largest permissible argument for SIN and COS nag_machine_sinarg_max (x02ah)
Largest representable integer nag_machine_integer_max (x02bb)
Maximum number of decimal digits that can be represented nag_machine_decimal_digits (x02be)
Parameters of model of floating point arithmetic, 
    b nag_machine_model_base (x02bh)
    emax nag_machine_model_maxexp (x02bl)
    emin nag_machine_model_minexp (x02bk)
    p nag_machine_model_digits (x02bj)

References

Brown W S (1981) A simple but realistic model of floating-point computation ACM Trans. Math. Software 7 445–480
ISO (1997) ISO Fortran 95 programming language (ISO/IEC 1539–1:1997)

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013