Table 33 Size differences between HP Fortran and C data types

HP Fortran data types

 

C data types

 

32-bit mode

64-bit mode

Sizes (in bits)

 

INTEGER

intor long

int

32

INTEGER*4

intor long

int

32

INTEGER*8

longlong

longor long long

64

REAL

float

float

32

DOUBLE PRECISION

double

double

64

REAL*16

long double

long double

128

Table 34 Size differences after compiling with +autodbl

HP Fortran data types

 

C data types

 

32-bit mode

64-bit mode

Sizes (in bits)

 

INTEGER

longor long

long

64

INTEGER*4

intor long

int

32

INTEGER*8

longlong

long

64

REAL

float

float

64

DOUBLE PRECISION

long double

long double

128

REAL*16

long double

long double

128

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

Page 111
Image 111
HP UX Fortran Software manual Unsigned integers, Logicals, Size differences between HP Fortran and C data types