Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

serious bug: Difference b/w Floating Point Precision in visual c++ 6.0 and visula studio 2008

$
0
0

Here i face a problem that when i am reading a floating point values from a text file (ex: 123.123567) it is reading as 123.12345670000001 like this.

I declared variable as :

              double a,b,c;                                         for eg: a=111.567 and b=123.12345

               fscanf("%lf",&a,&b);

           c=a-b;

 

            // and you will receive

            //

            //a=111.56699999999999

            //b=123.12340000000001

            //c=0.56699999999999307

            //

            //instead => a=111.567, b=123.12345, c=0.567;


But in visual c++ 6.0 it reads the value exactly same as in the file.

So,anyone please provide a solution for this.

With regards,

Krish


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>