Avoiding Pitfalls in Multi-Language Programming
Longint NA S9(18)COMP NA NA I(18)
Longreal REAL*8 NA double REAL R(7) #1
PAC of n CHARACTER*n PIC X(n) char [n] x$ X(n) #2
String CHARACTER*(*) NA char [n] x$ X(n) #2
Real REAL*4 NA float SHORT REAL R(6) #1
Shortint INTEGER*2 S9(4) COMP short SHORT INTEGER I(4)
NOTES:
#1 Transact also has a type E (Real Scientific Notation) that is the same as REAL in storage. Fortran
has a REAL*16 that has no other language equivalents. In Cobol, you can use the Compiler Library
routines PEXTIN and HPINEXT to convert real data types to/from data types that Cobol can
manipulate.
#2 Cobol and Transact support other character data types such as numeric-only and uppercase
characters. RPG also supports the character datatype. Strings are stored in different formats that are
generally incompatible across languages.
Table 2
Data Representation Equivalences Across Languages
Not so compatible data types across languages with best equivalents:
(~ denotes size equivalency but not identical computationally)
Pascal Fortran Cobol C Basic Transact Note ---------------------------------------------
----------------------------------------------------------------------
Bit16 ~INTEGER*2 9(4) COMP unsigned short ~SHORT INTEGER K(4) #3
Bit32 ~INTEGER*4 9(9) COMP unsigned int ~INTEGER K(9) #3
Bit52 NA 9(18) COMP NA NA K(18) #3
Boolean LOGICAL*1 NA ~character NA NA
~Record COMPLEX NA ~struct ~SHORT REAL ~R(6) #4
Enum NA NA enum NA NA #5
Pointer NA NA pointer NA NA
Record RECORD record struct ~x$ NA #6
Set NA NA ~struct NA NA
NA NA COMP-3 NA NA P #7
Page
3
of
14
Avoiding Pitfalls in Multi
-
Language Programming
7/18/2008
http://www.hp.com/cgi
-
bin/pf
-
new.cgi?IN=http://jazz.external.hp.com/papers/lang/pgm_pi
...