?
Solved

format double

Posted on 2006-06-27
3
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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