English
Language : 

CC78K4 Datasheet, PDF (67/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 4 TYPE CONVERSIONS
4.1 Arithmetic Operands
(1) Characters and integers (general integral promotion)
The data types of char, short int, and int bit fields (whether they are signed or unsigned) or of objects that have
an enumeration type will be converted to int types if their values are within the range that can be represented
with int types. If not within the range, they will be converted to unsigned int types. These implicit type
conversions are referred to as “general integral general promotion”. All other arithmetic types will not be
changed by this general integral promotion.
In general integral promotion, the value of the original data type is retained, including its sign. char type data
without a type qualifier will normally be handled as signed char in this compiler.
If can also be handled as unsigned char by using an option.
(2) Signed integers and unsigned integers
When a value with an integer type is converted to another, the value will not be changed if the value can be
expressed by the integer type after conversion.
When a signed integer is converted to an unsigned integer of the same or larger size, the value is not changed
unless the value of the signed integer is negative. If the value of the signed integer is negative and the unsigned
integer has a size larger than that of the signed integer, the signed integer is expanded to the signed integer with
the same size as the unsigned integer, and then it is added to the value equal to the maximum number that can
be expressed with the unsigned integer plus 1, and the signed integer before conversion is converted to the
unsigned value.
When a value with an integer type is converted to an unsigned integer with a smaller size, the conversion result
is the non-negative remainder of the value divided with that value which 1 is added to the maximum number that
can be expressed with an unsigned integer after conversion. When a value with an integer type is converted to a
signed integer with smaller size or when an unsigned integer is converted to a signed integer with the same size,
the overflowed value is ignored if the value after conversion cannot be expressed. For the conversion pattern,
refer to Table 4-1. List of Conversions between Types.
Conversion operations from signed integral type to unsigned integral type are as listed in Table 4-2 below.
Table 4-2. Conversions from Signed Integral Type to Unsigned Integral Type
signed
unsigned
Smaller in Value Range
Greater in Value Range
+
/
{
–
/
+
{:Type conversion will be performed properly.
+: The data will be converted to a positive integer.
/: The result of the conversion will be the remainder of the integer value, modulo the largest
possible value of the type to be converted plus 1.
User’s Manual U15556EJ1V0UM
67