Sign in Join
Wiki copytemporary

Revision 1 of 1, by Trev on 2-10-2020. The page as it is now.

Byte/fi

Byte on etumerkitön kokonaisluku alueella 0 .. 255. Se on 8 bittiä pitkä. Byte ja Char ovat samoja asioita paitsi byte voi viitata vain numereeniseen tyyppiin kun taas char käytetään merkeillä tai osana merkkijonoa. Eikä char:a voi käyttää matemaattisissa lausekkeissa.

Esimerkiksi:

pascal
 Var c: byte; 
 ch: char;

 begin
   c := 65;  ch := 'A';  { are the same action, and are legal }
   c := 'A'; ch := 65;   { while they are the same action, this is illegal }
 end.

Käyttämällä Byte:ä tai Char:a tietotyyppinä saadaan parempi dokumentaatio muuttujan yksityiskohtaisesta käyttäytymisestä. Byte-tyyppi voidaan pakottaa char:ksi käyttämällä chr-funktiota. Char-ttyppi voidaan pakottaa byte:ksi käyttämällä ord-funktiota.

yllä oleva ohjelma korjattuna:

pascal
 Var c: byte; 
 ch: char;

 begin
   c := 65;  ch := 'A'; { are the same action, and are legal }
   c := ord('A'); ch := Chr(65); { now legal }
 end.

From the Free Pascal wiki, page "Byte/fi", as it stood on 2020-02-10 after a change by Trev, 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.