Technical data
Implementation-defined Behavior [10]
10.1.2.5 Integers
All integral values are represented in a twos complement format. For
representation and memory storage requirements for integral types, see Table 6,
page 142.
When an integer is converted to a shorter signed integer, and the value cannot
be represented, the result is the truncated representation treated as a signed
quantity. When an unsigned integer is converted to a signed integer of
equal length, and the value cannot be represented, the result is the original
representation treated as a signed quantity.
The bitwise operators (unary operator ~ and binary operators <<, >>, &, ^, and
|) operate on signed integers in the same manner in which they operate on
unsigned integers. The result of
E1 >> E2, where E1 is a negative-valued signed
integral value, is E1 right-shifted E2 bit positions; vacated bits are filled with
0s on UNICOS systems and 1s on UNICOS/mk systems. On UNICOS/mk
systems, this behavior can be modified by using the -h nosignedshifts
option (see Section 2.7.4, page 15).
On UNICOS/mk systems, the shift operators (>> and <<) use only the rightmost
six bits of the second operand. For example, shifting by 65 is the same as shifting
by 1. On UNICOS systems, bits higher than the sixth bit are not ignored. Values
higher than 63 cause the result to be 0.
The result of the / operator is the largest integer less than or equal to the
algebraic quotient when either operand is negative and the result is a
nonnegative value. If the result is a negative value, it is the smallest integer
greater than or equal to the algebraic quotient. The / operator behaves the
same way in C and C++ as in Fortran.
The sign of the result of the percent (%) operator is the sign of the first operand.
Integer overflow is ignored. Because some integer arithmetic uses the
floating-point instructions on UNICOS systems, floating-point overflow can
occur during integer operations. Division by 0 and all floating-point exceptions,
if not detected as an error by the compiler, can cause a runtime abort.
10.1.2.6 Floating-point Arithmetic
Cray systems use either Cray floating-point arithmetic or IEEE floating-point
arithmetic. These types of floating-point representation are described in the
sections that follow.
S–2179–36 145










