`Word' data type et al._(re)
Mon, 16 Jun 1997 20:17:00 -0700
Frank Heckenbach wrote:
>=20
> Peter Gerwinski wrote:
>=20
> > I noticed a lot of confusion about Integer types in GNU Pascal.
>=20
> So did I (read: I was confused in the beginning ;-). I was going to
> post something about it sometime anyway...
>=20
> > 32 Integer Word [unsigned] int =3D=3D long
> > 64 LongInt LongWord [unsigned] long long
> >
etc etc=20
You may be interested to know the answer given by Borland to the same
problem in Delphi 2.0 when going from 16 bit to 32 bit system.=20
The following is a cut out of the Delphi help (in french however):
-------------------------------------------------------------------
Les types entiers pr=E9d=E9finis de Pascal Objet sont
divis=E9s en types fondamentaux et g=E9n=E9riques.
Les applications doivent utiliser les formats
entiers g=E9n=E9riques chaque fois que c'est possible,
car cela entra=EEne de meilleures performances pour
le processeur et le syst=E8me d'exploitation.=20
Les types entiers fondamentaux devraient n'=EAtre
utilis=E9s que lorsque l'intervalle r=E9el et/ou le
format de stockage sont importants pour l'application.
Types fondamentaux
Les types d'entiers fondamentaux sont :
Type Intervalle Format
Shortint -128 .. 127 Sign=E9, 8 bits
SmallInt -32768 .. 32767 Sign=E9, 16 bits
Longint -2147483648 .. 2147483647 Sign=E9, 32 bits
Byte 0 .. 255 Non sign=E9, 8 bits
Word 0 .. 65535 Non sign=E9, 16 bits
L'intervalle et le format des types fondamentaux=20
sont ind=E9pendants du processeur et du syst=E8me=20
d'exploitation et ne changent pas avec les=20
diff=E9rentes impl=E9mentations de Pascal Objet.
Types g=E9n=E9riques
Les types entiers g=E9n=E9riques sont Integer et Cardinal.=20
Le type Integer type repr=E9sente un entier sign=E9 g=E9n=E9rique
et le type Cardinal type repr=E9sente un entier non sign=E9
g=E9n=E9rique. les intervalles r=E9els et les formats de
stockage des types g=E9n=E9riques varient avec les=20
diff=E9rentes impl=E9mentations de Pascal Objet,=20
mais permettent g=E9n=E9ralement les op=E9rations sur=20
les entiers les plus efficaces pour le processeur=20
et le syst=E8me d'exploitation.
Type Intervalle Format
Integer -32768 .. 32767 Sign=E9, 16 bits
Integer -2147483648 .. 2147483647 Sign=E9, 32 bits
Cardinal 0 .. 65535 Non sign=E9, 16 bits
Cardinal 0 .. 2147483647 Non sign=E9, 32 bits
------------------------------------------------------------
=20
The idea is exactly the same as that contained in the letter of
Frank Heckenbach of today, except for the replacement of=20
Ordinal by Cardinal (which was also suggested by Franck).
So I would vote to implement what is proposed by Franck,
with only the replacement of ordinal by cardinal to have
some compatibility. i.e.
=20
Generic Types
Integer Cardinal
Well defined types
int8 card8 (=3Dbyte is the only case without doubt)
int16 card16
int32 card32
...
card9 =3D 0..2 POW 9 -1 ... if needed: this is always
allowed by the pascal syntax
but the amount of memory involved
is implementation dependant:
Compatibility types
=20
anything contained in bpcompat.pas delphi1compat.pas
delphi2compat.pas and everything you need,
better than compiler switches when possible to
avoid to garble the compiler by a lot of special
purpose oddities: the idea of C to keep a minimum
in the compiler and a maximum in libraries is
not so bad (when it is possible).
--=20
Maurice Lombardi
Lab. Spectrometrie Physique, Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex FRANCE
Tel: (33) 04 7651 4751. Fax (33) 04 7651 4544.
Maurice Lombardi (Maurice.LOMBARDI@ujf-grenoble.fr)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es