Reputation: 256541
Which is it?
From System.FixedInt documentation:
type FixedInt = Integer;
Defines a 32-bit signed integer type.
The size of FixedInt is 32 bits across all 64-bit and 32-bit platforms. The range for the FixedInt type is from -2147483648 through 2147483647.
- On Windows platforms (32-bit and 64-bit Windows), FixedInt is equivalent to the LongInt type.
Ok, so FixedInt is "equivalent" to LongInt (on Windows; which I am on). Which is confirmed in the source:
System.pas
{$IFDEF MSWINDOWS}
FixedInt = LongInt;
FixedUInt = LongWord;
{$ENDIF}
We check the System.LongInt documentation:
type Longint = { built-in type };
Platform-dependent signed integer type.
LongInt represents a subset of the natural numbers. LongInt size and range depend on the target platform:
On 32-bit platforms and 64-bit Windows platforms, LongInt is an 4-byte signed integer with the range [-2147483648 .. 2147483647]. (-2-31 through 232-1).
Note: 32-bit platforms include 32-bit Windows and Android.
On 64-bit POSIX platforms (Android, iOS, Linux, and macOS), LongInt is an 8-byte signed integer with the range [-9223372036854775808 .. 9223372036854775807] (-263 through 263-1).
Note: If you want to use a 4-byte signed integer type, use Integer or FixedInt.
So summarize
So which is it?
Is FixedInt really both 32-bit and 64-bit depending on 32-bit or 64-bit platform? Or is this simply a documentation bug?
Upvotes: 0
Views: 207
Reputation: 23026
FixedInt
and Integer
are both platform-independent, 32-bit integer types.
The documentation for System.FixedInt introduces an unnecessary distinction between equivalent types on different platforms:
- On Windows platforms (32-bit and 64-bit Windows), FixedInt is equivalent to the LongInt type.
- On OSX32, 32-bit iOS, 64-bit iOS, and Android platforms, FixedInt is equivalent to the Integer type.
By stating the equivalence on Windows in terms of LongInt
(a platform dependent type), the fact that this equivalence applies only on Windows means that if you click-thru to the documentation for the LongInt
type, you have to remember that to understand how it is equivalent to FixedInt
in the context of that platform.
This is not helped by the fact that the FixedInt
documentation establishes a context of "Windows platforms" and helpfully clarifies with "32-bit and 64-bit Windows". If you then read the LongInt
documentation, a similar phrase is encountered: "32-bit platforms and 64-bit Windows platforms". But this now means ALL 32-bit platforms (including but not limited to 32-bit Windows) AND in addition 64-bit Windows.
i.e. FixedInt
is always 32-bit, and on Windows, LongInt
is also 32-bit.
Meanwhile, the FixedInt
equivalence for other platforms is stated as Integer
, a platform independent type.
It would have been equally valid to say, "FixedInt is equivalent to Integer on all platforms", and leave it at that.
In other words, the documentation is not wrong but less clear than it might be, requiring careful reading. :)
Upvotes: 3