C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
HP C Implementation-Defined Behavior
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
A-3
G.3.5 Integers
The value of an integer character constant that contains more than one character
or a wide character that contains more than one multibyte character, for character
constants with 2 to 4 characters, is:
2 characters "ab"
'a' * 256 + (unsigned) 'b'
3 characters "abc"
'a' * 65536 + (unsigned) 'b' * 256 + (unsigned) 'c'
4 characters "abcd"
'a' * 16777216 + (unsigned) 'b' * 65536+ (unsigned) 'c' * 256 + (unsigned) 'd'
The C locale is used to convert multibyte characters into corresponding wide
character codes. The value of the wide character is equal to the value of the first
byte in the multibyte sequence (whose value is taken as an unsigned value).
A plain char has the same range of values as unsigned char.
G.3.5 Integers
Converting an integer to a shorter signed integer causes a representation change by
discarding the high order bits. Converting an unsigned integer to a signed integer of
equal length does not cause a representation change; however, the converted value
may be negative. The unsigned long long data type is supported for both TNS/R
and TNS/E-targeted compilations.
Bitwise operations on signed integers produce signed results, represented in two's
complement. How the value is interpreted depends on whether the sign bit is on or off
after the operation. The operation is performed on the data as though the values were
unsigned.
When the operator is % (remainder on integer division) these are true:
If the dividend is negative and the divisor is positive, the result is negative.
If the dividend is positive and the divisor is negative, the result is negative.
If both are negative the result is negative.
A right shift of a negative signed integral type causes the sign bit to be replicated.
(The shift is an arithmetic shift instead of a logical shift.)
G.3.6 Floating Point
Native C and C++ support two floating-point formats (IEEE and Tandem), beginning at
the G06.06 release. Tandem floating-point is further described in G.3.6 Floating Point
on page A-18.