Link to home
Start Free TrialLog in
Avatar of Giampete
Giampete

asked on

How to convert a Double precision number into a string but showing only two decimal places in C++

Am trying to print a number showing only two decimal places ;  this is after
calculating in double precision then converting the number into a string.

I need to do something in between I think... would appreciate some help have also attached the code

fastcall TForm3::TForm3(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::SpeedButton1Click(TObject *Sender)
{
double  m,dd,c,d,db,f,fc,asr,b,as_min;
 
 m=Umoment->Text.ToDouble();
 dd=Ddepth->Text.ToDouble();
 c=Co->Text.ToDouble();
 db=d_bar->Text.ToDouble();
 f=fy_reo->Text.ToDouble();
 fc=fc_concrete->Text.ToDouble();
 b=B_width->Text.ToDouble();
 
 
 
 d=dd-c-db*0.5;
 
 
 asr=(1-sqrt(1-3000000*m/(b*d*d*fc)))/(1.2*(f/(b*d*fc)));
 as_min=b*d*0.22*pow((dd/d),2)*0.6*(sqrt(fc))/f;
 
 
 d_depth->Text=String(d);
 Astr->Text=String(asr);
 
 Astm->Text=String(as_min);
 
 
return;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EE_AutoDeleter
EE_AutoDeleter

I've requested that this question be deleted for the following reason:

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Not enough information to confirm an answer.

If you feel this question should be closed differently, post an objection and a moderator will read all objections and then close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Auto Deleter
Actually, there is enough information.  Both George and I submitted workable solutions.