?
Solved

Decimals..

Posted on 2003-03-12
7
Medium Priority
?
207 Views
Last Modified: 2010-04-04
Hi!
I have a number Ex 3.636589745 and i want to round it but keep one descimal.
In this case i will be left with the result 3.6

How do I do this?

Thanx!
0
Comment
Question by:micfro
[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
  • 2
  • 2
  • +1
7 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 8118005
Hi micfro.

Check if FormatFloat() fits your needs.

Markus
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8118006
inclde Math in uses clausule, then:

function TForm1.DoubleRound(Number: Double;Digits: Byte):Double;
var fac: Extended;
begin
  fac:=Power(10,digits);
  Number:=Number*fac;
  Number:=Round(Number);
  Result:=Number/fac;
end;

procedure TForm1.Button1Click(Sender: TObject);
var x,y: Double;
begin
  x:=3.636589745;
  y:=DoubleRound(x,1);
  ShowMessage('y: '+FloatToStr(y));
end;

ziolko.
0
 
LVL 10

Expert Comment

by:kacor
ID: 8118034
Hi micfro,

the simplest way to multiply by 10, round, then divide by 10

wbr

Janos
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:micfro
ID: 8118095
Thank you very much!

You all solved my little problem :)

micfro
0
 
LVL 10

Accepted Solution

by:
kacor earned 300 total points
ID: 8118423
Hi micfro,

please don't forget accept somebody's answer. Otherwise we all are glad to help you.

wbr

Janos
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8118439
all comments helpfull... I'll sugest points for everyone :-))
ziolko.
0
 

Author Comment

by:micfro
ID: 8118440
Ok, I'm new to this forum! But thank you for telling me :)

micfro
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
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

770 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