program test;

{$MODE OBJFPC}

(*

https://freepascal.org/docs-html/ref/refsu4.html#x26-250003.1.1

With the exception of floating point value types, all base types

are ordinal types.

A list of predefined integer types is presented in table (3.1).

Remark: The compiler decides on the type of an integer constant

based on the value: An integer constant gets the smallest possible

signed type. The first match in table (3.3) is used.

That means constants in the range -128..127 are mapped to shortint,

constants in range 128..255 are mapped to byte, etc.

Constants in the range 2147483647..high(cardinal) are parsed as

cardinals, and all decimal constants which do not fit either of

the above ranges are parsed as 64-bit integer constants.

As a pascal compiler, Free Pascal does automatic type conversion and

upgrading in expressions where different kinds of integer types are

used:

1 Every platform has a “native” integer size, depending on whether

the platform is 8-bit, 16-bit, 32-bit or 64-bit. E. g. on AVR this

is 8-bit.

2 Every integer smaller than the “native” size is promoted to a

signed version of the “native” size. Integers equal to the “native”

size keep their signedness.

3 The result of binary arithmetic operators (+, -, *, etc.) is

determined in the following way:

a If at least one of the operands is larger than the native integer

size, the result is chosen to be the smallest type that encompasses

the ranges of the types of both operands. This means that mixing an

unsigned with a smaller or equal in size signed will produce a

signed type that is larger than both of them.

b If both operands have the same signedness, the result is the same

type as them. The only exception is subtracting (-): in the case of

unsigned - unsigned subtracting produces a signed result in FPC

(as in Delphi, but not in TP7).

c Mixing signed and unsigned operands of the “native” int size

produces a larger signed result. This means that mixing longint and

longword on 32-bit platforms will produce an int64. Similarly,

mixing byte and shortint on 8-bit platforms (AVR) will produce

a smallint.

*)

begin

WriteLn(64);

WriteLn(SizeOf(64));

WriteLn(128);

WriteLn(SizeOf(128));

WriteLn(128 or 64);

WriteLn(SizeOf(128 or 64));

WriteLn(not(128 or 64));

WriteLn(SizeOf(not(128 or 64)));

end.

(*

64

1

128

1

192

1

-193

8

*)