Difference between revisions of "maxint/fr"

From Free Pascal wiki
Jump to navigationJump to search
(m)
 
m (Fixed syntax highlighting)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{maxint}}
 
{{maxint}}
 +
<br>
 
<br>
 
<br>
 
'''MAXINT''' est un constante globale, égale à la limite supérieure du type [[Integer/fr|integer]], [http://www.moorecad.com/standardpascal/iso7185.html#6.7.2.2%20Arithmetic%20operators per the ISO 7185 standard].
 
'''MAXINT''' est un constante globale, égale à la limite supérieure du type [[Integer/fr|integer]], [http://www.moorecad.com/standardpascal/iso7185.html#6.7.2.2%20Arithmetic%20operators per the ISO 7185 standard].
Line 11: Line 12:
 
L'exemple suivant illustre comment ces valeurs sont articulées :
 
L'exemple suivant illustre comment ces valeurs sont articulées :
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
program maxvals;
 
program maxvals;
 
   const width = 20;
 
   const width = 20;

Latest revision as of 00:41, 21 February 2020

Deutsch (de) English (en) suomi (fi) français (fr)


MAXINT est un constante globale, égale à la limite supérieure du type integer, per the ISO 7185 standard.

Notez que cette valeur varie avec le compilateur indépendamment des capacités de la machine hôte ou de la cible (donc portabilité assurée entre des machines différentes ayant la même compilateur).

Si vous voulez contrôler la taille de l'espace d'adressage, contrôlez sizeof(pointer).

Si vous voulez savoir si vous exécuter sur un CPU avec 64-bit ALU, contrôlez si le symbole cpu64 est défini.

L'exemple suivant illustre comment ces valeurs sont articulées :

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.

Comparez le résultat avec -Mtp puis -Mobjfpc, par exemple :

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