C++ compiler problems with FC2

Ed Hill ed at eh3.com
Tue Aug 31 01:17:01 UTC 2004


On Mon, 2004-08-30 at 21:04, Robert L Cochran wrote:
> > Does this compile for you
> > 
> > #include <iostream>
> > #include <cmath>
> > 
> > using namespace std;
> > 
> > int main()
> > {
> >   cout << "sine 63 = " << sin(63) << endl;
> >   cout << "log to the base 10 of 54 = " << log10(54) << endl;
> >   double quick = (sin(53) * sqrt(14.3443) + tanh(22)) / log(61.444);
> >   cout << "quick = " << quick << endl;
> > }


Yes, explicitly converting those constants to doubles is a good idea:

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  cout << "sine 63 = " << sin(double(63)) << endl;
  cout << "log to the base 10 of 54 = " << log10(double(54)) << endl;
  double quick = (sin(double(53)) * sqrt(double(14.3443)) 
    + tanh(double(22))) / log(double(61.444));
  cout << "quick = " << quick << endl;
}

which then compiles cleanly on my FC2 install (gcc 3.3.3).

Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Rm 54-1424;  77 Massachusetts Ave.
             Cambridge, MA 02139-4307
emails:  eh3 at mit.edu                ed at eh3.com
URLs:    http://web.mit.edu/eh3/    http://eh3.com/
phone:   617-253-0098
fax:     617-253-4464





More information about the fedora-test-list mailing list