Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


FloatToStr problem

Posted on 1999-07-21
Medium Priority
Last Modified: 2012-08-14
I am currently experiencing a problem related to the FloatToStr function.  The problem occurs when the Decimal symbol setting on Windows Regional Settings Properties (Numbers Tab) is blank.  When I pass 43.59 to FloatToStr it returns ‘43 59’.  Is there any way to ensure that FloatToStr retains the decimal point ?

I would be grateful for all help offered regarding this problem.

Thanks in advance

John Clarke
Question by:johnclarke
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 1390186
I don't think you can fix it with just FloatToStr but could you just replace the space with a decimal point?  I can't think of any other way you'd have spaces in a FloatToStr result.  If so, try this:

var str: string;
     i: integer;

str := FloatToStr('0.00', 123.45);

//convert spaces to points:
for i := 1 to length(str) do
  if str[i] = ' ' then str[i] := '.';

If this is OK let me know and I'll submit it as an answer so you can grade it.
LVL 27

Accepted Solution

kretzschmar earned 200 total points
ID: 1390187
hi johnclarke,

at appstart, for example in the formcreate-event
set this global var

 DecimalSeparator := '.';  //or what you want as DecimalSeparator

(hope it works, just not tested)

LVL 27

Expert Comment

ID: 1390188
oops, sorry jsexton, had not seen your comment ;-)
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 1390189
no problem meikl, your answer is better anyway.  John, try meikl's suggestion first - it should work fine.

LVL 27

Expert Comment

ID: 1390190

have done test and it works

the globalvar is defined in the unit sysutils, which should be added automatically by the ide, if not, then add this unit by hand in the uses-clause.

meikl ;-)

Expert Comment

ID: 1390191
I use

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question