Go to main content
Oracle® Developer Studio 12.5: Numerical Computation Guide

Exit Print View

Updated: June 2016
 
 

5.2 LIA-1 Conformance

In this section, LIA-1 refers to ISO/IEC 10967-1:1994 Information Technology - Language Independent Arithmetic - Part 1: Integer and floating-point arithmetic.

The C and Fortran 95 compilers (cc and f95) contained in the Sun Studio compilers release conform to LIA-1 in the following senses (paragraph letters correspond to those in LIA‐1 section 8):

E.2.1 a. TYPES (LIA 5.1):

The LIA-1 conformant types are C int and Fortran INTEGER. Other types can conform as well, but they are not specified here. Further specifications for specific languages await language bindings to LIA-1 from the cognizant language standards organizations.

E.2.2 b. PARAMETERS (LIA 5.1):

#include <values.h> /* defines MAXINT */
#define TRUE 1
#define FALSE 0
#define BOUNDED TRUE
#define MODULO TRUE
#define MAXINT 2147483647
#define MININT ‐2147483648
 logical bounded, modulo
 integer maxint, minint
 parameter (bounded = .TRUE.)
 parameter (modulo = .TRUE.)
 parameter (maxint = 2147483647)
 parameter (minint = ‐2147483648)

E.2.3 d. DIV/REM/MOD (LIA 5.1.3):

C / and %, and Fortran / and mod(), provide DIVtI(x,y) and REMtI(x,y). Also, modaI(x,y) is available with the following code:

int modaI(int x, int y) {
 int t = x % y;
 if (y < 0 && t > 0)
 t ‐= y;
 else if (y > 0 && t < 0)
 t += y;
  return t;
 }

It is also available with the following code:

 integer function modaI(x, y)
 integer x, y, t
 t = mod(x, y)
 if (y .lt. 0 .and. t .gt. 0) t = t ‐ y
 if (y .gt. 0 .and. t .lt. 0) t = t + y
 modaI = t
 return
 end

E.2.4 i. NOTATION (LIA 5.1.3):

The following table shows the notation by which the LIA integer operations can be realized.

Table 43  LIA‐1 Conformance ‐ Notation
LIA
C
Fortran if different
addI(x,y)
x+y
n/a
subI(x,y)
x‐y
n/a
mulI(x,y)
x*y
n/a
divtI(x,y)
x/y
n/a
remtI(x,y)
x%y
mod(x,y)
modaI(x,y)
see above
n/a
negI(x)
‐x
n/a
absI(x)
#include <stdlib.h>
abs(x)
abs(x)
signI(x)
#define signI(x) (x > 0
? 1 : (x < 0 ? ‐1 : 0))
see below
eqI(x,y)
x==y
x.eq.y
neqI(x,y)
x!=y
x.ne.y
lssI(x,y)
x<y
x.lt.y
leqI(x,y)
x<=y
x.le.y
gtrI(x,y)
x>y
x.gt.y
geqI(x,y)
x>=y
x.ge.y

The following code shows the Fortran notation for signI(x).

integer function signi(x)
integer x, t
if (x .gt. 0) t=1
if (x .lt. 0) t=‐1
if (x .eq. 0) t=0
return
end

E.2.5 j. EXPRESSION EVALUATION:

By default, when no optimization is specified, expressions are evaluated in int (C) or INTEGER (Fortran) precision. Parentheses are respected. The order of evaluation of associative unparenthesized expressions such as a + b + c or a * b * c is not specified.

E.2.6 k. METHOD OF OBTAINING PARAMETERS:

Include the definitions in b. PARAMETERS (LIA 5.1): in your source code.

E.2.7 n. NOTIFICATION:

Integer exceptions are x/0 and x%0 or mod(x,0). By default, these exceptions generate SIGFPE. When no signal handler is specified for SIGFPE, the process terminates and dumps memory.

E.2.8 o. SELECTION MECHANISM:

signal(3) or signal(3F) can be used to enable user exception handling for SIGFPE.