Solved

Converting a real number to string

Posted on 2000-04-10
2
136 Views
Last Modified: 2010-04-04
How do you convert a real number to string type??
0
Comment
Question by:Dushi
2 Comments
 
LVL 15

Accepted Solution

by:
simonet earned 50 total points
ID: 2702479
There are many ways to do it:

1) By using FloatToStr
   The string representaion keeps the same number of decimal place as the original number

Ex.:   Str := FloatToStr(MyRealNumber);

2) By using Format
   You can specify how the final string will look like

Ex.: Str := Format('%.4f', [PI]);

{ Str evaluates to '3.1428' }

Yours,

Alex
0
 

Expert Comment

by:scirocco1
ID: 2703498
You can use:
function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision,
  Digits: Integer): string;

Ex:
DesireString := FloatToStrF(YourValue,ffFixed,7,4);
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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