SPL to HP C/XL Migration Guide (30231-90001)
5-1
Chapter 5 Expressions, Assignments, and Scan Statements
This chapter discusses conversion issues related to sections in Chapter
4 of the
Systems Programming Language Reference Manual
.
Expression Types
Table 5-1. Expression Types
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Variables on either side of an operator | Variable types may be mixed in expressions. |
| must be of the same type. Type transfer | Automatic type conversion is performed |
| functions are used to convert types. | prior to execution of an operator. See "HP |
| | C/XL Rules for Automatic Numeric Type |
| | Conversion" in this chapter. |
| | |
| | A "cast" operator may be used to force an |
| | expression to a desired data type, perhaps |
| | for an actual parameter to a function. |
| | |
---------------------------------------------------------------------------------------------
| The type transfer functions are the names | The corresponding cast operators are |
| of the simple variable types, plus two | similar to SPL, except that the
type names
|
| | |
| additions, in the function form: | are enclosed in parentheses: |
| | |
| BYTE (
double | integer | logical
) | (unsigned char) (
expression
) |
| DOUBLE (
byte | integer | logical
) | (long int) (
expression
) |
| FIXR (
real
) rounds to DOUBLE |
(No equivalent)
|
| FIXT (
real
) truncates to DOUBLE | (long int) (
expression
) |
| INTEGER (
byte | double | logical
) | (short int) (
expression
) |
| LOGICAL (
byte | double | integer
) | (unsigned short int) (
expression
) |
| LONG (
double | real
) | (double) (
expression
) |
| REAL (
byte | double | integer |
| (float) (
expression
) |
|
logical | long
) | |
| | The
expression
may have any appropriate |
|
byte
,
double
,
integer
,
logical
,
long
, and | character or numeric value. The |
|
real
are the types permitted in the | parentheses around
expression
may be |
| particular functions. | omitted if it is a single entity. |
| | Conversion from float or double to any char |
| Sometimes more than one function is | or int type is by truncation. There is no |
| required, as in the conversion from REAL to | rounding function. HP C/XL also allows |
| INTEGER, which requires either | other simple data and pointer types in cast |
| "INTEGER(FIXR(
real
))" or | operations. |
| "INTEGER(FIXT(
real
))". | |
---------------------------------------------------------------------------------------------
HP C/XL Rules for Automatic Numeric Type Conversion
As an expression is evaluated, HP C/XL performs automatic data type
conversions on the operands. First, each operand is evaluated and
converted, according to Table 5-2.