Difference between revisions of "Byte/fr"

From Free Pascal wiki
Jump to navigationJump to search
(New page: {{Byte}} A '''byte''' is an unsigned integer in the range of 0 .. 255. A byte and a char are the same thing, except a byte can only be referred to as a numeric type, while a cha...)
 
m (Fixed syntax highlighting)
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Byte}}
 
{{Byte}}
  
A '''byte''' is an unsigned integer in the range of 0 .. 255. A byte and a [[Char|char]] are the same thing, except a byte can only be referred to as a numeric type, while a char can be used as a character, or as part of a string type, and cannot be used in an arithmetic expression.
+
un '''Byte''' est un [[Integer/fr|entier]] non signé dans l'intervalle de 0 .. 255. Un octet est composé de 8 bits. Un octet et un [[Char/fr|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.
  
For example:
+
Par exemple :
<tt>
+
<syntaxhighlight lang="pascal">
: Var c: byte;  
+
Var c: byte;  
: ch: char;
+
ch: char;
:
 
: begin
 
: {{Tab4}}  c := 65;  ch := 'A';  { are the same action, and are legal }
 
: {{Tab4}}  c := 'A'; ch := 65;  { while they are the same action, this is illegal }
 
: end.
 
</tt>
 
  
The use of byte or char as a data type provides better documentation as to the purpose of the use of the particular variable. The byte type can be [[coersion|coerced]] to char by using the '''[[chr]]''' function. Char type values can be coerced to byte by using the '''[[ord]]''' function
+
  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.
 +
</syntaxhighlight>
  
The above program corrected to legal use:
+
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 [[coersion/fr|converti]] en type char en employant la fonction '''[[Chr/fr|chr]]'''.  Les valeurs de type Char peuvent être converties en byte en employant la fonction '''[[Ord/fr|ord]]'''
  
<tt>
+
Le programme ci-dessus corrigé pour une utilisation légale:
: Var c: byte;
 
: ch: char;
 
:
 
: begin
 
: {{Tab4}}  c := 65;  ch := 'A'; { are the same action, and are legal }
 
: {{Tab4}}  c := ord('A'); ch := Chr(65); { now legal }
 
: end.
 
</tt>
 
  
{{Data types}}
+
<syntaxhighlight lang="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.
 +
</syntaxhighlight>
  
 
+
{{Data types/fr}}
[[category:Pascal]]
 

Latest revision as of 07:28, 10 February 2020

Deutsch (de) English (en) español (es) suomi (fi) français (fr) italiano (it) русский (ru) 中文(中国大陆)‎ (zh_CN)

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 :

 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:

 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.
Types de données
Types de données simples Boolean | Byte |Cardinal | Char | Currency | Extended | Int64 | Integer | Longint | Pointer | Real | Shortint | Smallint | Word
Types de données complexes Array | Class | Record | Set | String | ShortString