maxint/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: maxint/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **MAXINT** on [[Constant/fi|vakio]], joka vastaa [[Integer/fi|kokonaisluvutyypin]] ylärajaa [ISO 7185 -standardin](http://www.moorecad.com/standardpascal/iso7185.html#6.7.2.2%20Arithmetic%20operators) mukaan. | |
| 2 | + | ||
| 3 | + | Huomaa, että tämä arvo muuttuu [[Compiler Mode/fi|kääntäjän tilan]] perusteella eikä sillä ole mitään tekemistä isäntä- tai kohdekoneen ominaisuuksien kanssa. | |
| 4 | + | ||
| 5 | + | Jos halutaan tarkistaa osoiteavaruuden koko niin se tarkistetaan **[[SizeOf/fi|sizeof]]([[Pointer/fi|pointer]])** käskyllä. | |
| 6 | + | ||
| 7 | + | Jos halutaan tietää, onko käytössä CPU, jossa on [[64 bit|64-bittinen]] ALU niin tarkistetaan, onko symbolia **cpu64** määritetty. | |
| 8 | + | ||
| 9 | + | Seuraava esimerkki kuvaa, miten nämä arvot liittyvät: | |
| 10 | + | ||
| 11 | + | ``` pascal | |
| 12 | + | program maxvals; | |
| 13 | + | const width = 20; | |
| 14 | + | begin | |
| 15 | + | writeln; | |
| 16 | + | writeln( 'these change depending on compiler mode:' ); | |
| 17 | + | writeln( '----------------------------------------' ); | |
| 18 | + | writeln( 'maxint: :', maxint : width ); | |
| 19 | + | writeln( 'high( integer ) :', high( integer ) : width ); | |
| 20 | + | writeln; | |
| 21 | + | writeln( 'constant, regardless of mode or target: ' ); | |
| 22 | + | writeln( '----------------------------------------' ); | |
| 23 | + | writeln( 'high( int32 ) :', high( int32 ) : width ); | |
| 24 | + | writeln( 'high( int64 ) :', high( int64 ) : width ); | |
| 25 | + | writeln; | |
| 26 | + | writeln( 'variable, depending on target cpu:' ); | |
| 27 | + | writeln( '----------------------------------------' ); | |
| 28 | + | writeln( 'sizeof( pointer ) :', sizeof( pointer ) : width ); | |
| 29 | + | writeln; | |
| 30 | + | writeln( 'compile-time definitions:' ); | |
| 31 | + | writeln( '----------------------------------------' ); | |
| 32 | + | {$IFDEF cpu64} writeln( 'cpu64' ); {$ENDIF} | |
| 33 | + | {$IFDEF cpu32} writeln( 'cpu32' ); {$ENDIF} | |
| 34 | + | {$IFDEF cpu16} writeln( 'cpu16' ); {$ENDIF} | |
| 35 | + | writeln; | |
| 36 | + | end. | |
| 37 | + | ``` | |
| 38 | + | ||
| 39 | + | Vertaile tuloksia kääntäjän tiloilla [[Mode TP|-Mtp]] vs [[Mode ObjFPC|-Mobjfpc]], esimerkiksi: | |
| 40 | + | ||
| 41 | + | fpc -Mtp maxvals.pas && ./maxvals | |
| 42 | + | fpc -Mobjfpc maxvals.pas && ./maxvals | |
| 43 | + | ||
| 44 | + | --- | |
| 45 | + | *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](/wiki-contact).* |
