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++ / May 2006

Tip: Looking for answers? Try searching our database.

double type precision in VC7

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kingkong - 08 May 2006 22:25 GMT
Hi,

I am porting some code from VC6 to .net 2003 VC7.1.  The code is to do
yield curve interpolation, therefore precision is important.  I have
found some strange behavior in the VC7.1 environment.  Allow me to show
the problem:

...
    double_v    strikes;
    strikes.reserve(11);
    strikes.push_back(0.00750);
    strikes.push_back(0.01965);
    strikes.push_back(0.02000);
    strikes.push_back(0.02076);
    strikes.push_back(0.05000);
    strikes.push_back(0.09000);
...
When I examine the values in strikes in the VC6 debugger, I can see the
exact number that I inserted.  In the VC7.1 debugger, some of the
numbers in strikes are different by a very small fraction.  The numbers
shown in the VC71 debugger are:

strikes._M_start,6
    [0]    0.0074999999999999997
    [1]    0.019650000000000001
    [2]    0.020000000000000000
    [3]    0.020760000000000001
    [4]    0.050000000000000003
    [5]    0.089999999999999997

I am using stlport4.6.2 which I don't think it is the cause of the
problem.  I am new to the MS environment, even newer to the VC71 world.
My question is why these 2 environments are different and how to work
around it.  

Any advice will be greatly appreciated.

MK
Carl Daniel [VC++ MVP] - 08 May 2006 23:42 GMT
> Hi,
>
[quoted text clipped - 32 lines]
>
> Any advice will be greatly appreciated.

You're being misled into believing that you have different problems in VC7
that you had in VC6.  Please read

http://docs.sun.com/source/806-3568/ncg_goldberg.html

before you do anything else.

The difference is simply in how the debugger displays the double data type.
VC6 rounds to 6 (or so) digits, while VC7 doesn't.

-cd

Rate this thread:







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.