# Integers

This section describes the implementation-defined characteristics of
integers.
It corresponds to section ``F.3.5 Integers'' in the
ANSI document.

## Integer range and representation

Integers are represented as follows:

char == signed char
unsigned char
short == signed short
unsigned short

int == signed int == long == signed long
unsigned int == unsigned long

**NOTE:**
The section ``C Implementation Limits description'',
later in this appendix, presents the range of values each integer
type can take on.

## Demotion of integers

When an integer is converted to a shorter signed integer, if the
value cannot be represented, the excess bytes are truncated.
For example if:

char c = (char) 0xabcdef;

then the value of **c** is 0xef.
When an unsigned integer is converted to a signed integer
of equal length, if the value cannot be represented,
the conversion is the same, but the value is treated
like a signed number.

## Signed bitwise operations

In bitwise operations on signed integers, each of the
operands of a bitwise operation is subject to the ``usual
arithmetic conversions''.
Consequently, narrow integers are subject to ``integral
promotions''.
For example, a **short** is promoted into an
**int**. If the value of the **short**
is negative, the sign is extended in the **int**.
After the promotion, bitwise operations on signed **int**s are
applied as if they were applied on unsigned **int**s.

## Sign of division remainder

When integers are divided and the division is inexact,
the sign of the remainder is the same as the sign of the dividend.

## Right shift of negative-valued signed integer

When a signed integral type with a negative value is
right shifted, the sign is extended.

*
Next topic:
Floating point
*

Previous topic:
Characters

© 2003 Caldera International, Inc. All rights reserved.

SCO OpenServer Release 5.0.7 -- 11 February 2003