473,769 Members | 6,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

floating point model differences in VS2005 and VS2003

1 New Member
Hi,
We are working on a scientifical related product which is most sensitive towards mathematical functions (even 7th decimal place chang can cause considereble differences in the output values). We’ve observed that the trignometric functions are behaving differently in Visual C++ 2003 and Visual C++ 2005 versions. We've recently upgraded IDE from VS2003 to VS2005 and compiled the unmanaged vc++ code in both versions.
To explain this in detail, please consider the following console application and compile it in both 2003 and 2005 versions.

Expand|Select|Wrap|Line Numbers
  1. // CosSinDemo.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <math.h>
  5.  
  6. const float  PI           = 3.1415926535f;
  7. const float  PI_OVER_180  = PI / 180.0f;
  8.  
  9. int _tmain(int argc, _TCHAR* argv[])
  10. {
  11.     static double fDummy1     = 0;
  12.     static double fDummy2     = 0;
  13.  
  14.     float fDiffLat = -0.19629669; //
  15.     float fDiffLon =  0.060424805;
  16.  
  17.     fDummy1      = cos( fDiffLon * PI_OVER_180);
  18.     fDummy2      = cos( -fDiffLat* PI_OVER_180);
  19.     printf("fDummy1 - %3.20f\nfDummy2 - %3.20f", fDummy1, fDummy2);
  20.     return 0;
  21. }
  22. output with VS2005:
  23. fDummy1 - 0.99999946355819702000
  24. fDummy2 - 0.99999415874481201000
  25. output with VS2003:
  26. fDummy1 - 0.99999944389707407000
  27. fDummy2 - 0.99999413118713976000
The values are differing in 7th decimal place.
Currently we've made Floating point model as /fp:precise in VS2005, could you please someone help me out on how to make VS2005 cos/sin functions behave same as was there in 2003 version.
Oct 12 '06 #1
0 1971

Sign in to post your reply or Sign up for a free account.

Similar topics

31
3683
by: JS | last post by:
We have the same floating point intensive C++ program that runs on Windows on Intel chip and on Sun Solaris on SPARC chips. The program reads the exactly the same input files on the two platforms. However, they generate slightly different results for floating point numbers. Are they really supposed to generate exactly the same results? I guess so because both platforms are supposed to be IEEE floating point standard (754?) compliant. ...
15
3933
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this the EPSILON? I know in float.h a FLT_EPSILON is defined to be 10^-5. Does this mean that the computer cannot distinguish between 2 numbers that differ by less than this epsilon?
3
1799
by: Darrin | last post by:
Hello, I see that VS2005 and the new framework 2.0 is out to the public now. Wondering about some things. When you install the new framework 2.0 can a person still use visual studio 2003 or do you need to use Visual Studio 2005? If you can use the new framework 2.0 with VS2003 are there any benifits?
8
2968
by: Jon Rea | last post by:
Hi, I have just tried compiling some scientific calculation code on Redhad Linux using gcc-3.4.4 that I normally compile on MS Visual C++ 03 and 05. I was surprised to get different floating point answers on the two systems (identical hardware spec AMD Athlon). Both are being compiled in 'Debug' mode with things like Fast_Math disabled. After a little debuging and lots of printf() statements, all my errors are found to be cumulative...
9
1336
by: DrZogg | last post by:
It can't be... say it isn't so... Yes.. there is a fly in the ointment This bug requires 3 projects... yes this is a real world production issue not some tinker toy thing. Start with a C# interface assembly we will call Interfaces namespace Interfaces {
70
3637
by: Robert Gamble | last post by:
9899:1999 5.1.2.3 Example 4 reads: "EXAMPLE 4 Implementations employing wide registers have to take care to honor appropriate semantics. Values are independent of whether they are represented in a register or in memory. For example, an implicit spilling of a register is not permitted to alter the value. Also, an explicit store and load is required to round to the precision of the storage type. In particular, casts and assignments are...
0
1002
by: A W | last post by:
Hello, I am encountering the following scenario while compiling a project under Visual Studio 2005 with the floating point model set as precise. Two executables A and B share a common dll C. Both call the function func() in C with the same input and get slightly different floating point results. Below is what func() looks like: const long double pi = atanl(1.0) * 4.0;
8
1606
by: Spam Catcher | last post by:
Hi all, From what I read, VS.NET 2005 doesn't precompile web applications into a DLL for deployment, rather you need to manually precompile before release. However, I have a web application in my project and it is compiling like in ..NET 1.1 - it is generating a set of deployment DLLs. Does anyone know why it is doing that? Does VS.NET 2005 still support both deployment models?
39
3579
by: rembremading | last post by:
Hi all! The following piece of code has (for me) completely unexpected behaviour. (I compile it with gcc-Version 4.0.3) Something goes wrong with the integer to float conversion. Maybe somebody out there understands what happens. Essentially, when I subtract the (double) function value GRID_POINT(2) from a variable which has been assigned the same value before this gives a non-zero result and I really do not understand why.
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9993
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.