Sign in Join
Wiki copytemporary

Byte/fr

Deutsch · English · Español · Français · Italiano · Suomi · Русский · 中文(中国)

un Byte est un entier non signé dans l'intervalle de 0 .. 255. Un octet est composé de 8 bits. Un octet et un char sont la même chose, excepté qu'un octet peut seulement être désigné comme de type numérique, tandis qu'un char peut être employé comme caractère, ou en tant qu'élément de type chaîne de caractères, et ne peut pas être employé dans une expression arithmétique.

Par exemple :

pascal
 Var c: byte; 
 ch: char;

 begin
   c := 65;  ch := 'A';  { ils ont la même action , et c'est légal }
   c := 'A'; ch := 65;   { alors qu'ils ont la même action , c'est illégal  }
 end.

L'utilisation de byte ou de char comme type de données fournit une meilleure documentation quant au but de l'utilisation d'une variable particulière. Le type byte peut être converti en type char en employant la fonction chr. Les valeurs de type Char peuvent être converties en byte en employant la fonction ord

Le programme ci-dessus corrigé pour une utilisation légale:

pascal
 Var c: byte; 
 ch: char;

 begin
   c := 65;  ch := 'A'; { ils ont la même action , et c'est légal }
   c := ord('A'); ch := Chr(65); { légal maintenant ! }
 end.

From the Free Pascal wiki, page "Byte/fr", 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.

Revision 1, last changed by WikiArchive .

Talk about this page

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