473,320 Members | 1,695 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,320 software developers and data experts.

floating point model differences in VS2005 and VS2003

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 1953

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

Similar topics

31
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....
15
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...
3
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...
8
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...
9
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#...
70
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...
0
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. ...
8
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...
39
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.