Sign in Join
Wiki copytemporary

maxint/fi

Deutsch · English · Français · Suomi

MAXINT on vakio, joka vastaa kokonaisluvutyypin ylärajaa ISO 7185 -standardin mukaan.

Huomaa, että tämä arvo muuttuu kääntäjän tilan perusteella eikä sillä ole mitään tekemistä isäntä- tai kohdekoneen ominaisuuksien kanssa.

Jos halutaan tarkistaa osoiteavaruuden koko niin se tarkistetaan sizeof(pointer) käskyllä.

Jos halutaan tietää, onko käytössä CPU, jossa on 64-bittinen ALU niin tarkistetaan, onko symbolia cpu64 määritetty.

Seuraava esimerkki kuvaa, miten nämä arvot liittyvät:

pascal
program maxvals;
  const width = 20;
begin
  writeln;
  writeln( 'these change depending on compiler mode:' );
  writeln( '----------------------------------------' );
  writeln( 'maxint:           :', maxint : width );
  writeln( 'high( integer )   :', high( integer ) : width );
  writeln;
  writeln( 'constant, regardless of mode or target: ' );
  writeln( '----------------------------------------' );
  writeln( 'high( int32 )     :', high( int32 ) : width );
  writeln( 'high( int64 )     :', high( int64 ) : width );
  writeln;
  writeln( 'variable, depending on target cpu:' );
  writeln( '----------------------------------------' );
  writeln( 'sizeof( pointer ) :', sizeof( pointer ) : width );
  writeln;
  writeln( 'compile-time definitions:' );
  writeln( '----------------------------------------' );
  {$IFDEF cpu64} writeln( 'cpu64' ); {$ENDIF}
  {$IFDEF cpu32} writeln( 'cpu32' ); {$ENDIF}
  {$IFDEF cpu16} writeln( 'cpu16' ); {$ENDIF}
  writeln;
end.

Vertaile tuloksia kääntäjän tiloilla -Mtp vs -Mobjfpc, esimerkiksi:

pascal
fpc -Mtp maxvals.pas && ./maxvals
fpc -Mobjfpc maxvals.pas && ./maxvals

From the Free Pascal wiki, page "maxint/fi", as it stood on 2019-06-30 after a change by Djzepi, 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.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 1 person, 2019

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
DjzepiCreated page
Djzepi

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.