Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2007

Tip: Looking for answers? Try searching our database.

Best Practice for Dealing with double inaccuracies

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JBeerhalter@gmail.com - 13 Apr 2007 01:25 GMT
I understand why doubles are not entirely accurate(i.e. if I store the
number .10 in a double it might actually have the value .
100000000001), I was just curious if someone could direct me toward
best practices for dealing with them.

I could cleary eschew double in favor of decimal, or just constantly
round everything, but these seem to involve alot of overhead that I'd
rather not deal with.

-JB
David Wilkinson - 13 Apr 2007 02:25 GMT
> I understand why doubles are not entirely accurate(i.e. if I store the
> number .10 in a double it might actually have the value .
[quoted text clipped - 4 lines]
> round everything, but these seem to involve alot of overhead that I'd
> rather not deal with.

Why do you think it matters? If you are doing something that would be
defeated by this "inaccuracy", don't do it.

Signature

David Wilkinson
Visual C++ MVP

Carl Daniel [VC++ MVP] - 13 Apr 2007 04:18 GMT
> I understand why doubles are not entirely accurate(i.e. if I store the
> number .10 in a double it might actually have the value .
[quoted text clipped - 4 lines]
> round everything, but these seem to involve alot of overhead that I'd
> rather not deal with.

Use your favorite web search tool to find the article "What every computer
scientist should know about floating point arithmetic".  There are various
copies of it all over the place.  It'll tell you more than you wanted to
know (but not more than you need to know!)

-cd

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.