HP Fortran Programmer Guide (766160-001, March 2014)
Table 33 Size differences between HP Fortran and C data types
Sizes (in bits)
C data types
HP Fortran data types
64-bit mode32-bit mode
32intintor longINTEGER
32intintor longINTEGER*4
64longor long longlonglongINTEGER*8
32floatfloatREAL
64doubledoubleDOUBLE PRECISION
128long doublelong doubleREAL*16
Table 34 Size differences after compiling with +autodbl
Sizes (in bits)
C data types
HP Fortran data types
64-bit mode32-bit mode
64longlongor longINTEGER
32intintor longINTEGER*4
64longlonglongINTEGER*8
64floatfloatREAL
128long doublelong doubleDOUBLE PRECISION
128long doublelong doubleREAL*16
The following sections provide more detailed information about language differences for the
following data types:
• Unsigned integers
• Logicals
• Complex numbers
• Derived types
Unsigned integers
Unlike Fortran, C allows integer data types (char,int,short, and long) to be declared as either
signed or unsigned. If a Fortran program passes a signed integer to a C function that expects an
unsigned integer argument, C will interpret the bit pattern as an unsigned value.
An unsigned integer in C can represent twice the number of positive values as the same-sized
integer in HP Fortran. If an HP Fortran program calls a C function that returns an unsigned integer
and the return value is greater than can be represented in a signed integer, HP Fortran will interpret
the bit pattern as a negative number.
Logicals
C uses integers for logical types. In HP Fortran, a 2-byte LOGICALis equivalent to a C short, and
a 4-byte LOGICALis equivalent to a long or int. In C and HP Fortran, zero is false and any nonzero
value is true. HP Fortran sets the value 1for true.
Data types 111