Typecast/fr
Deutsch · English · Français · Русский
La conversion de variables à plus faible amplitude vers des variables de plus forte amplitudes est faite automatiquement (implicite), de byte vers integer par exemple.
Dans le sens inverse, la conversion d'une valeur d'un type vers un autre de plus faible amplitude demande un cast ou un appel de fonction, et si la valeur de départ ne s'ajuste pas dans le type de donnée cible alors de la donnée sera perdue.
=Conversion de type=\
Type de donnée source
Type de donnée cible
Type de conversion
Méthode
Integer
Real
implicite
instruction d'affectation
Real
Integer
explicite:
Perd la partie fractionnelle
Arrondit la partie entière
Trunc
Round
Integer
String
explicite
IntToStr
Real
String
explicite
FloatToStr
FloatToStrF
String
Integer
explicite
StrToInt
String
Real
explicite
StrToFloat
String
Char
explicite
String[index]
Char/AnsiChar/WideChar
String
implicite
instruction d'affectation
Char/AnsiChar
Byte
explicite
Ord
Byte(valeur char)
Byte
Char/AnsiChar
explicite
Chr
AnsiChar(valeur byte)
Enuméré type
String
explicite
WriteStr(string-var,enum-var)
Type de donnée source
Type de donnée cible
Type de conversion
Méthode
QWord
Byte
explicite
Byte(QWord)
QWord
Word
explicite
Word(QWord)
QWord
Cardinal
explicite
Cardinal(QWord)
QWord
Longword
explicite
Longword(QWord)
Longword
Byte
explicite
Byte(Longword)
Longword
Word
explicite
Word(Longword)
Longword
Cardinal
implicite
assignment statement
Int64
Byte
explicite
Byte(Int64)
Int64
Shortint
explicite
Shortint(Int64)
Comp
Byte
explicite
Byte(Comp)
Comp
Shortint
explicite
Shortint(Comp)
Comp
Real
explicite
Real(Comp)
From the Free Pascal wiki, page "Typecast/fr", as it stood on 2016-12-16 after a change by E-ric, 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.
