Sign in Join
Wiki copytemporary

DecimalSeparator/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11**DecimalSeparator** (séparateur décimal) est une [[Global variables|variable char globale]] dont le contenu est déterminé par la [[locale/fr|locale]] utilisée. Elle est utilisée pour la représentation des nombres flottants sous forme de chaîne de caractères dans les fonctions StrToFloat() et FloatToStr().
22
33Aussi longtemps que toutes les instances d'un programme utilise le même séparateur décimal, tout se passera comme prévu. Toutefois, si l'une des instances du programme est basée sur la locale holllandaise (nl_NL) et écrit un fichier contenant des nombres flottants formatés et qu'une autre instance lit ces données avec une locale anglaise US (en_US), vous allez avoir un problème car un nombre formaté comme 123,456 va provoqué une exception de conversion... (la virgule n'est pas le séparateur décimal de cette locale.)
44
55Un palliatif pouvant être utilisé :
66
77``` pascal
88function DecFloat2Str( const d: double ): string;
99var
1010 myseparator: char;
1111begin
1212 myseparator := DecimalSeparator;
1313 DecimalSeparator := '.';
1414 Result := FloatToStr( d );
1515 DecimalSeparator := myseparator;
1616end;
1717```
1818
1919DecimalSeparator est défini dans sysinth.inc comme:
2020
21-` DecimalSeparator : Char absolute DefaultFormatSettings.DecimalSeparator deprecated;`
21+```text
22+ DecimalSeparator : Char absolute DefaultFormatSettings.DecimalSeparator deprecated;
23+```
2224
2325NB : cette variable est marquée obsolète, il faut employer DefaultFormatSettings.DecimalSeparator à la place.
2426
2527## Voir aussi
2628
2729- [[ThousandSeparator/fr]]
2830- [[ListSeparator/fr]]
2931- [Documentation sur DecimalSeparator](http://www.freepascal.org/docs-html/rtl/sysutils/decimalseparator.html)
3032
3133---
3234*From the Free Pascal wiki, page "DecimalSeparator/fr", as it stood on 2020-02-12 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](/wiki-contact).*

Back to history