[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

format double

Posted on 2006-06-27
3
Medium Priority
?
291 Views
Last Modified: 2010-04-24
currently im converting a Standard::String to a double - this is the code im using

retArray[i] = System::Convert::ToDouble(strArray[i]);

as you can see, i have two arrays, one of doubles, the other of strings.

now it goes fine -  except for example i have a string value of "0.70", after the conversion the value in the double array is 0.699999999

shouldnt be that big of a deal, but im doing a number of iterations after that value is obtained, and i want it to be exact.

any idea how to get the value in after its passed to be 0.700000000????

thanks in advance

~b
0
Comment
Question by:bramsquad
3 Comments
 
LVL 30

Assisted Solution

by:Axter
Axter earned 248 total points
ID: 16997168
Hi bramsquad,
> any idea how to get the value in after its passed to be 0.700000000????
A double is not an exact number.
If you need higher precission, you need to use a different type.

Cheers!
0
 
LVL 8

Author Comment

by:bramsquad
ID: 16997352
thanks axter,

different type like what?

~b
0
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 252 total points
ID: 16998026
Try to get the object's value using

Object* defaultValue== __box( Convert::ToDouble( strArray[i]) );

check value here

retArray[i] = *dynamic_cast<__box Double*>(obj);

Also you can use the IFormatProvider class to change the formatting.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

872 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