Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Decimals..

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
micfro
Asked:
micfro
  • 2
  • 2
  • 2
  • +1
1 Solution
 
DaFoxCommented:
Hi micfro.

Check if FormatFloat() fits your needs.

Markus
0
 
ziolkoCommented:
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
 
kacorretiredCommented:
Hi micfro,

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

wbr

Janos
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
micfroAuthor Commented:
Thank you very much!

You all solved my little problem :)

micfro
0
 
kacorretiredCommented:
Hi micfro,

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

wbr

Janos
0
 
ziolkoCommented:
all comments helpfull... I'll sugest points for everyone :-))
ziolko.
0
 
micfroAuthor Commented:
Ok, I'm new to this forum! But thank you for telling me :)

micfro
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now