English
Language : 

CC78K0S Datasheet, PDF (72/520 Pages) NEC – C Compiler Ver.1.30 or Later 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.
General integral promotion will retain the value of the original data type including its sign.
char type data without a type qualifier will normally be handled as signed char in this compiler. It can be
handled as an unsigned char 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 with 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 with 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 a non-negative remainder which the value is 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 overflown 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.
72
User’s Manual U14872EJ1V0UM