Everything
4.1.3 Internal representation and value area of data

This section explains the internal representation and value area of each type for the data handled by the CC-RH.

(1)

Integer type

(a)

Internal representation

The leftmost bit in an area is a sign bit with a signed type (type declared without "unsigned"). The value of a signed type is expressed as 2' s complement.

 

Internal Representation of Integer Type are shown below.

-

_Bool

Only the 0th bit has meaning. Bits 1 to 7 are undefined.

If the -lang=c option is specified simultaneously with the -strict_std option, _Bool type will cause a C90 violation error.

 

-

char

 

-

signed char (no sign bit for unsigned)

 

-

short (no sign bit for unsigned)

 

-

int, long (no sign bit for unsigned)

 

-

long long (no sign bit for unsigned)

If the -lang=c option is specified simultaneously with the -strict_std option, long long type will cause a C90 violation error.

 

(b)

Value area

Table 4.1

Value Area of Integer Type

Type

Value Area

charNote

-128 to +127

short

-32768 to +32767

int

-2147483648 to +2147483647

long

-2147483648 to +2147483647

long long

-9223372036854775808 to +9223372036854775807

unsigned char

0 to 255

unsigned short

0 to 65535

unsigned int

0 to 4294967295

unsigned long

0 to 4294967295

unsigned long long

0 to 18446744073709551615

(c)

Integer constants

The type of an integer constant will be the first type in the lists below capable of representing that value.

Table 4.2

Types of Integer Constants (when -lang=c is specified and -strict_std is not specified)

Suffix

Decimal Constant

Octal Constant or Hexadecimal Constant

None

int

long int

unsigned long intNote

long long int

unsigned long long int

int

unsigned int

long int

unsigned long int

long long int

unsigned long long int

u or U

unsigned int

unsigned long int

unsigned long long int

unsigned int

unsigned long int

unsigned long long int

l or L

long int

unsigned long intNote

long long int

unsigned long long int

long int

unsigned long int

long long int

unsigned long long int

Both u or U, and l or L

unsigned long int

unsigned long long int

unsigned long int

unsigned long long int

ll or LL

long long int

unsigned long long int

long long int

unsigned long long int

Both u or U, and ll or LL

unsigned long long int

unsigned long long int

Note

Different from C99 specification

Table 4.3

Types of Integer Constants (when -lang=c and -strict_std are specified)

Suffix

Decimal Constant

Octal Constant or Hexadecimal Constant

None

int

long int

unsigned long int

int

unsigned int

long int

unsigned long int

u or U

unsigned int

unsigned long int

unsigned int

unsigned long int

l or L

long int

unsigned long int

long int

unsigned long int

Both u or U, and l or L

unsigned long int

unsigned long int

Table 4.4

Types of Integer Constants (when -lang=c99 is specified)

Suffix

Decimal Constant

Octal Constant or Hexadecimal Constant

None

int

long int

long long int

unsigned long long int

int

unsigned int

long int

unsigned long int

long long int

unsigned long long int

u or U

unsigned int

unsigned long int

unsigned long long int

unsigned int

unsigned long int

unsigned long long int

l or L

long int

long long int

unsigned long long int

long int

unsigned long int

long long int

unsigned long long int

Both u or U, and l or L

unsigned long int

unsigned long long int

unsigned long int

unsigned long long int

ll or LL

long long int

unsigned long long int

long long int

unsigned long long int

Both u or U, and ll or LL

unsigned long long int

unsigned long long int

(2)

Floating-point type

(a)

Internal representation

Internal Representation of floating-point data type conforms to IEEE754Note. The leftmost bit in an area of a sign bit. If the value of this sign bit is 0, the data is a positive value; if it is 1, the data is a negative value.

Note

IEEE: Institute of Electrical and Electronics Engineers
IEEE754 is a standard to unify specifications such as the data format and numeric range in systems that handle floating-point operations.

 

Internal Representation of Floating-Point Type are shown below.

-

__fp16

S: Sign bit of mantissa

E: Exponent (5 bits)

M: Mantissa (10 bits)

 

-

float

S: Sign bit of mantissa

E: Exponent (8 bits)

M: Mantissa (23 bits)

 

-

double, long double

S: Sign bit of mantissa

E: Exponent (11 bits)

M: Mantissa (52 bits)

 

(b)

Value area

Table 4.5

Value Area of Floating-Point Type

Type

Value Area

__fp16

6.10352e-05F to 65504.0

float

1.17549435E-38F to 3.40282347E+38F

double

2.2250738585072014E-308 to 1.7976931348623158E+308

long double

2.2250738585072014E-308 to 1.7976931348623158E+308

When -Xdbl_size=4 is specified, the double and long double types have the same internal representation and the same value area as those of the float type.

(3)

Pointer type

(a)

Internal representation

The internal representation of a pointer type is the same as that of an unsigned int type.

Figure 4.1

Internal Representation of Pointer Type

(4)

Enumerate type

(a)

Internal representation

The internal representation of an enumerate type is the same as that of a signed int type. The leftmost bit in an area of a sign bit.

Figure 4.2

Internal Representation of Enumerate Type

 

When the -Xenum_type=auto option is specified, see "(32) The integer type chosen to represent the values of an enumeration type (6.5.2.2).".

(5)

Array type

(a)

Internal representation

The internal representation of an array type arranges the elements of an array in the form that satisfies the alignment condition (alignment) of the elements

Example

char    a[8] = {1, 2, 3, 4, 5, 6, 7, 8};

 

The internal representation of the array shown above is as follows.

Figure 4.3

Internal Representation of Array Type

(6)

Structure type

(a)

Internal representation

The internal representation of a structure type arranges the elements of a structure in a form that satisfies the alignment condition of the elements.

Example

struct {
        short   s1;
        int     s2;
        char    s3;
        long    s4;
} tag;

 

The internal representation of the structure shown above is as follows.

Figure 4.4

Internal Representation of Structure Type

 

For the internal representation when the structure type packing function is used, see "4.2.6.8 Structure type packing".

(7)

Union type

(a)

Internal representation

A union is considered as a structure whose members all start with offset 0 and that has sufficient size to accommodate any of its members. The internal representation of a union type is like each element of the union is placed separately at the same address.

Example

union {
        int     u1;
        short   u2;
        char    u3;
        long    u4;
} tag;

 

The internal representation of the union shown in the above example is as follows.

Figure 4.5

Internal Representation of Union Type

(8)

Bit field

(a)

Internal representation

The most significant bit of a bit field declared as a signed type, or without an explicit sign declaration, will be the sign bit. The first bit field to be declared will be allocated starting from the least significant bit in the area with the sign of the type when the bit field was declared. If the alignment condition of the type specified in the declaration of a bit field is exceeded as a result of allocating an area that immediately follows the area of the preceding bit field to the bit field, the area is allocated starting from a boundary that satisfies the alignment condition.

You can allocate the members of a bit field starting from the most significant bit using the -Xbit_order=left option or by specifying #pragma bit_order left. See "4.2.6.9 Bit field assignment" for details.

Example 1.

struct {
        unsigned int    f1:30;
        int             f2:14;
        unsigned int    f3:6;
} flag;

 

The internal representation for the bit field in the above example is as follows.

Figure 4.6

Internal Representation of Bit Field

Example 2.

struct {
    int             f1:5;
    char            f2:4;
    int             f3:6;
} flag;

The internal representation for the bit field in the above example is as follows.

Figure 4.7

Internal Representation of Bit Field

 

The types that can be specified for bit fields are _Bool, char, signed char, unsigned char, signed short, unsigned short, signed int, unsigned int, signed long, unsigned long, signed long long, unsigned long long, and enumerated types. However, only signed int and unsigned int types can be specified when the -lang=c option and -strict_std option are specified.

For the internal representation of bit field when the structure type packing function is used, see "4.2.6.8 Structure type packing".

(9)

Alignment condition

(a)

Alignment condition for basic type

Alignment condition for basic type is as follows.

If the -Xinline_strcpy option of the CC-RH is specified, however, all the arrey types are 4-byte boundaries.

Table 4.6

Alignment Condition for Basic Type

Basic Type

Alignment Conditions

(unsigned) char and its array type

_Bool type

Byte boundary

(unsigned) short and its array type

2-byte boundary

Other basic types (including pointer)

(unsigned) long long and its array type

double and its array type

4-byte boundary

long double and its array type

4-byte boundary

(b)

Alignment condition for union type

The alignment conditions for a union type are the same as those of the structure's member whose type has the largest alignment condition.

 

Here are examples of the respective cases:

Example 1.

union  tug1 {
  unsigned short i; /*2 bytes member*/
  unsigned char  c; /*1 bytes member*/
};  /*The union is aligned with 2-byte.*/

Example 2.

union  tug2 {
  unsigned int  i;  /*4 bytes member*/
  unsigned char  c; /*1 byte member*/
};  /*The union is aligned with 4-byte.*/

(c)

Alignment condition for structure type

The alignment conditions for a structure type are the same as those of the structure's member whose type has the largest alignment condition.

 

Here are examples of the respective cases:

Example 1.

struct  ST {
        char    c;      /*1 byte member*/
};  /*Structure is aligned with 1-byte.*/

Example 2.

struct  ST {
        char    c;      /*1 byte member*/
        short   s;      /*2 bytes member*/
};  /*Structure is aligned with 2-byte.*/

Example 3.

struct  ST {
        char    c;      /*1 byte member*/
        short   s;      /*2 bytes member*/
        short   s2;     /*2 bytes member*/
};  /*Structure is aligned with 2-byte.*/

Example 4.

struct  ST {
        char    c;      /*1 byte member*/
        short   s;      /*2 bytes member*/
        int     i;      /*4 bytes member*/
};  /*Structure is aligned with 4-byte.*/

Example 5.

struct  ST {
        char        c;      /*1 byte member*/
        short       s;      /*2 bytes member*/
        int         i;      /*4 bytes member*/
        long long   ll;     /*4 bytes member*/
};  /*Structure is aligned with 4-byte.*/

(d)

Alignment condition for function argument

The alignment condition for a function argument is a 4-byte boundary.

(e)

Alignment condition for executable program

The alignment condition when an executable object module file is created by linking object files is 2-byte boundary.