Byte/it
Deutsch · English · Español · Français · Italiano · Suomi · Русский · 中文(中国)
Un byte è un intero senza segno che può assumere valori che vanno da 0 a 255. Un byte e un char sono la stessa cosa, con la differenza che il byte può contenere solo valori numerici, mentre il char può contenere un carattere o una parte di una stringa, e non può essere usato in espressioni aritmetiche.
Ad esempio:
var
c: byte;
ch: char;
begin
c := 65; ch := 'A'; { sono la stessa azione, ed è legittimo }
c := 'A'; ch := 65; { questo è illegittimo }
end.l'uso di char o byte come tipi di dato permette una migliore comprensione circa l'utilizzo di una determinata variabile. Il char può essere convertito in byte usando la funzione ord. I valori delle variabili di tipo byte possono essere convertiti in char tramite chr.
Il precedente programma reso legittimo:
var
c: byte;
ch: char;
begin
c := 65; ch := 'A'; { sono la stessa azione, e sono legittimi }
c := ord('A'); ch := Chr(65); { ora legittimo }
end.From the Free Pascal wiki, page "Byte/it", 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.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
