Solved

Converting a real number to string

Posted on 2000-04-10
2
138 Views
Last Modified: 2010-04-04
How do you convert a real number to string type??
0
Comment
Question by:Dushi
[X]
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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
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
Course of the Month10 days, 15 hours left to enroll

631 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