TIP: Click on subject to list as thread! ANSI
echo: delphi
to: JUD MCCRANIE
from: MARTIN MAAT
date: 1997-07-22 18:57:00
subject: CARDINAL

Hallo Jud
 JM> Is Delphi's (2&3) Cardinal type of much use, since it is simply a
 JM> subrange of integer?  It would be useful if it was a 32-bit
 JM> unsigned integer, but it is a 31-bit unsigned integer.  It is
 JM> simply an integer that can't be negative.  You can define this
 JM> subrange if you want it.
Help tells us:
Type  Range Format
Integer         -32768..     32767  Signed 16-bit
Cardinal             0..     65535  Unsigned 16-bit
Integer    -2147483648..2147483647  Signed 32-bit
Cardinal             0..2147483647  Unsigned 32-bit
So I figured the last 2147483647 had to be wrong and the reason why you 
thought the cardinal type was no good. In 16-bits environments we used the 
integer type word, so cardinal in 32-bit had to be the 32-bit equivalent of 
word, that is, 32-bit unsigned. Just to proove this I reluctantly started up 
Delphi 3, soon to find that... you are right! (you already knew that, didn't 
you?)
The compiler does not allow you to assign, say, 3 bilion to a cardinal. You 
can however dec, inc or shift out of the defined range and it will return 
negative values afterwards, it is really a 32 bit signed integer.
I don't see any point either. It seems to be purely conventional. Perhaps 
some Pascal definition demands a cardinal type. I do not understand why the 
real "longword" type was left out. It may be for performance reasons.
Groeten, Martin.
--- FMail/386 1.02
---------------
* Origin: -=[ E-mail: m_maat@knoware.nl .......... ]=- (2:286/420.1)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.