Sign in Join
Wiki copytemporary

DecimalSeparator

English · Français

Warning: This variable is deprecated. Please see hints for information on replacement.

DecimalSeparator is a global char variable whose contents is determined by the used locale. It is used for representation of floating point numbers on screen and within functions like StrToFloat() and FloatToStr().

As long as every instance of a program uses the same decimal separator everything will behave as expected. However, if one instance of a program has its locale set to Dutch (nl_NL), writes a file containing some floating point numbers which is read by another instance of the same program with a locale set to US-English (en_US) you run into trouble because a formatted number like 123,456 will generate a conversion exception...

A workaround can be to use a function like:

pascal
function DecFloat2Str( const d: double ): string;
var
   myseparator: char;
begin
  myseparator := DecimalSeparator;
  DecimalSeparator := '.';
  Result := FloatToStr( d );
  DecimalSeparator := myseparator;
end;

DecimalSeparator is defined in sysinth.inc as:

text
 DecimalSeparator : Char absolute DefaultFormatSettings.DecimalSeparator deprecated;

Important hint

DecimalSeparator is deprecated. In all new projects, it should be replaced by the DefaultFormatSettings variable.

See also


From the Free Pascal wiki, page "DecimalSeparator", as it stood on 2023-04-06 after a change by Jwdietrich, 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 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 4 people, 2015–2023

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
ArentCreated page
Arent
Arent
Arent
Arent
E-ric
TrevFixed syntax highlighting (minor)
TrevSee also: Added FPC ref (minor)
JwdietrichAdding hint that this variable is deprecated now.
Jwdietrich

Talk about this page

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