StrToFloatDef
Convertit une chaîne donnée en une valeur à virgule flottante, avec renvoi de def en cas d'erreur.
Syntaxe
function StrToFloatDef(str: String; def: Float): Float
str: chaîne
def: valeur par défaut
Remarques
Convertit une chaîne donnée en une valeur à virgule flottante, avec renvoi de def en cas d'erreur.
Cette fonction considère '.' et ',' comme étant des séparateurs décimaux.
Voir aussi StrToFloat & StrToInt.
Exemples
var s := 'zzz';
PrintLn( StrToFloatDef(s, 1.5) ); // 1.5
PrintLn( s.ToFloatDef(1.5) ); // 1.5
s := '2.5';
PrintLn( StrToFloatDef(s, 1.5) ); // 2.5
PrintLn( s.ToFloatDef(1.5) ); // 2.5
PrintLn( StrToFloatDef(s, 1.5) ); // 1.5
PrintLn( s.ToFloatDef(1.5) ); // 1.5
s := '2.5';
PrintLn( StrToFloatDef(s, 1.5) ); // 2.5
PrintLn( s.ToFloatDef(1.5) ); // 2.5