Sign in Join
Wiki copytemporary

MaxInt: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-\
21**MaxInt** is a global [[Constant|constant]], equal to the upper bound of the [[Integer|integer]] type, [per the ISO 7185 standard](http://www.moorecad.com/standardpascal/iso7185.html#6.7.2.2%20Arithmetic%20operators).
32
43Note that this value changes based on the [[Compiler Mode|compiler mode]] and has nothing to do with the capabilities of the host or target machine.
54
65If you want to check the size of the address space, check **[[SizeOf|sizeof]]([[Pointer|pointer]])**.
76
87If you want to know if you are running on a CPU with [[64 bit|64-bit]] ALU, check whether the symbol **CPU64** is defined.
98
109The following example illustrates how these values relate:
1110
1211``` pascal
1312program maxvals;
1413 const width = 20;
1514begin
1615 writeln;
1716 writeln( 'these change depending on compiler mode:' );
1817 writeln( '----------------------------------------' );
1918 writeln( 'maxint: :', maxint : width );
2019 writeln( 'high( integer ) :', high( integer ) : width );
2120 writeln;
2221 writeln( 'constant, regardless of mode or target: ' );
2322 writeln( '----------------------------------------' );
2423 writeln( 'high( int32 ) :', high( int32 ) : width );
2524 writeln( 'high( int64 ) :', high( int64 ) : width );
2625 writeln;
2726 writeln( 'variable, depending on target cpu:' );
2827 writeln( '----------------------------------------' );
2928 writeln( 'sizeof( pointer ) :', sizeof( pointer ) : width );
3029 writeln;
3130 writeln( 'compile-time definitions:' );
3231 writeln( '----------------------------------------' );
3332 {$IFDEF cpu64} writeln( 'cpu64' ); {$ENDIF}
3433 {$IFDEF cpu32} writeln( 'cpu32' ); {$ENDIF}
3534 {$IFDEF cpu16} writeln( 'cpu16' ); {$ENDIF}
3635 writeln;
3736end.
3837```
3938
4039Compare the results with [[Mode TP|-Mtp]] vs [[Mode ObjFPC|-Mobjfpc]], for example:
4140
4241 fpc -Mtp maxvals.pas && ./maxvals
4342 fpc -Mobjfpc maxvals.pas && ./maxvals
4443
4544---
4645*From the Free Pascal wiki, page "MaxInt", as it stood on 2023-12-22 after a change by Alextpp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history