The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Q: formatting double value in string
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hajo_old

Germany
141 Posts

Posted - 02/27/2003 :  08:26:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello, all

within my function I want to set the title of a graphics page with the following code snippet:

the variable ti is read out from an page.info value (I guess it is a double value within the page.info structure)



string legend;
legend = "\\b(Einspritzverläufe K" + kunde + ")\r\n";
legend = legend + "\\b(Vergleich der Einzelinjektoren - FUP: " + (int)fup + " [bar], ";
legend = legend + "t\-(i, main): " + ti + " [ms])";
LTCmd = "title.text$ = " + legend;
LT_execute(LTCmd);



this works so far. But the variable ti shows up as "0.658000000001"
and it should be only "0.658" as lable text!

How can I set the mantisse within a string to enshure it is shown on the graphics page as "0.658"!!

Thanks Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1

easwar

USA
1965 Posts

Posted - 02/27/2003 :  09:39:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hajo,

Look up the Format member function in the string class.
You can use that to place values in the string using a specified format.

For example,

string strPi;
strPi.Format("Value of pi = %5.2f", pi);
printf("%s\n", strPi);



Easwar
OriginLab.



Edited by - easwar on 02/27/2003 09:47:39 AM
Go to Top of Page

hajo_old

Germany
141 Posts

Posted - 02/27/2003 :  10:10:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Easwar

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000