[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/29/2009 at 09:21PM PDT, ID: 24857068 | Points: 125
[x]
Attachment Details

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

Asked by Giampete in C++ Builder

Tags: Embarcadero C++ 2010

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
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
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;
 
Keywords: How to convert a Double precision nu…
 
Loading Advertisement...
 
[+][-]10/30/09 05:12 AM, ID: 25702114

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/30/09 04:03 PM, ID: 25707332

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625