International Decimal "Points"

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

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. 

bulletMy Val procedure now ignores any embedded Thousandseparator characters in the input string.
bulletWhen writing the decimal separator header record to a file with text numeric data, both decimal and thousands separators are saved.  When reading the file back, the thousands separator, if present, is used to modify any occurrences found to the appropriate thousands separator character for the current locale.       

Click here to download  International Decimal  Demo source code

 

Created: March 12,  2005

Modified: July 29, 2017




  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.