473,414 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

double type precision in VC7

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

May 8 '06 #1
1 1118

"kingkong" <ma**********@us.hsbc.com> wrote in message
news:11*********************@y43g2000cwc.googlegro ups.com...
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.


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
May 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: J | last post by:
Would anyone know if there a type tag to format a double? I have f for floating point, but cannot find one for double.
4
by: Michael Mair | last post by:
Hi there, actually, I have posted the same question in g.g.help. As there were no answers, I am still not sure whether this is a bug or only something open to the compiler that is seemingly...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
10
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
67
by: lcw1964 | last post by:
This may be in the category of bush-league rudimentary, but I am quite perplexed on this and diligent Googling has not provided me with a clear straight answer--perhaps I don't know how to ask the...
60
by: Erick-> | last post by:
hi all... I've readed some lines about the difference between float and double data types... but, in the real world, which is the best? when should we use float or double?? thanks Erick
116
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused...
10
by: Bo Yang | last post by:
Hi, I am confused by the double type in C++. I don't know whether below is legal or possible: double PI = 3.141592675932; Now, can I get another double variable from PI with lower precision,...
29
by: Virtual_X | last post by:
As in IEEE754 double consist of sign bit 11 bits for exponent 52 bits for fraction i write this code to print double parts as it explained in ieee754 i want to know if the code contain any...
248
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.