Programs that use floating point numbers (i.e. with decimal points), need some special considerations to work correctly in countries whose decimal separator is not a dot, "." or that reads string versions of numbers generated by systems whose decimal separator does not agree with the user's system. 

Here are three tips for the programmer to avoid problems:

  1.  Always use the DecimalSeparator global variable rather than '.' or ',' when checking input or creating output string versions of floating point numbers.
  2.  Do not use the system Val procedure to convert strings to floating point numbers numbers. Val assumes that the decimal separator is a dot (.). The formatting procedure StrToFloat does handle decimal separator values correctly.   This program contains a replacement Val procedure which uses StrToFloat to correctly recognize the current separator.
  3.  If numeric floating point strings are written to text files, include a line identifying the decimal separator used. At input time, replace that character with the current decimal separator for the system reading the file.

Here's a program, DecimaSep,  than incorporates all three tips including a replacement for Delphi's "Val" procedure for testing. 

Addendum December 3, 2008: A viewer recently pointed out that the handling of decimal separators should also be prepared to handle the thousands separator since the US usage (x,xxx.xx) has the separator roles reversed in most of Europe (x.xxx,xx).  DecimalSep2 addresses this with two changes. 

Click here to download  International Decimal  Demo source code

 

Created: March 12,  2005

Modified: November 07, 2008