Installation guide
7.3.2 Constants
Check the use of constants in your program, particularly if you are going to
exchange data between 32-bit and 64-bit systems. Some constants might
have different values between 32-bit and 64-bit systems, which might
change the behavior of some operators. For example, hexadecimal
constants are more likely to become long on DIGITAL UNIX systems. The
following table lists some constants and their values:
C Constant Value Value (32-Bit) Value (64-Bit)
0xFFFFFFFF 2
32
−1 −1 4,294,967,295
4294967296
2
32
0
4,294,967,296
0x100000000
2
32
0
4,294,967,296
0xFFFFFFFFFFFFFFFF 2
64
−1 −1 −1
7.3.2.1 Integer and Long Constants—Assignment and Argument Passing
In C, an integer constant is specified as 543210. To specify a long int
constant, use the letter suffix L or l. To specify an unsigned long, you use
the UL or ul suffix. (L is preferred since lowercase l is easily confused with
the number one.) Note the example where three different constants are
passed to the function, labs():
labs(543210)
labs(543210L)
labs(543210UL)
On an Alpha system, 543210 is treated as a 4-byte constant, and 543210L
(or 543210UL) is treated as an 8-byte constant. If the labs() function
expects a long argument, each of these invocations would work as
expected since the int constants would be converted to long. If the
labs() function expects type int, the long constant would be truncated
to an integer constant. This truncation would result in the loss of
significant digits if the constant was greater than the maximum integer
constant (INT_MAX) of +2147483647, or less than the minimum integer
constant (INT_MIN) of −2147483648, or for unsigned constants greater
than the maximum unsigned integer constant (UINT_MAX) of 4294967295.
This problem would also be present in an assignment expression where a
long integer constant was assigned to a variable of type int. In these
cases, explicitly use the L or UL suffix and make sure the function
arguments or variables being assigned to are of the appropriate long type.
When you need to pass zero to a pointer argument and no function
prototype is visible, always use NULL (defined in the stdio.h file). Using
zero will result in using a 4-byte zero instead of a 8-byte zero (0L). In a
7–12 Migrating Your ULTRIX Application to a DIGITAL UNIX System