Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - sqrt() error
todouble() converts two ints, a numerator and a denominator, into a double and returns it. When I try to take the square root of the double, I get the errors below. As hard as it is to believe STLport will only take the square root of a float and a long double. (See _cmath.h, which is included in cmath.) When I cast the return of todouble() to long double it worked. std::cout << "Fraction x is " << x << "\tsqrt x is "<< std::sqrt(x.todouble()) << std::endl; ^ ftest6.cpp(40) : Error: ambiguous reference to symbol Had: std::_inline_sqrt(float ) and: std::_inline_sqrt(long double ) frac6WR.cpp: ftest6.cpp: --- errorlevel 1 Mar 18 2003
Some of math functions, and sqrt among them, are #define'd in math.h. Defines serve to promote sqrt/sin/cos an other calls to intrinsic calls. But this surely prevents normal usage of STL. When ported Blitz to DMC++, I used the code below to suppress this errors: ----------- #include <math.h> #undef sin #undef cos #undef fabs #undef sqrt inline double cos (double x) { return _inline_cos(x);} inline double sin (double x) { return _inline_sin(x);} inline double fabs (double x) { return _inline_fabs(x);} inline double sqrt (double x) { return _inline_sqrt(x);} ------------ You should insert it before you make calls to std::sqrt. Or even simpler solution, write sqrt instead of std::sqrt. Nic Tiger. "Jim Jennings" <jwjenn mindspring.com> сообщил/сообщила в новостях следующее: news:b57s60$16lp$1 digitaldaemon.com...todouble() converts two ints, a numerator and a denominator, into a double and returns it. When I try to take the square root of the double, I get Mar 18 2003
Thank you, Nic. This works. I have filed this away, and will use it in the future. JIm "Nic Tiger" <nictiger progtech.ru> wrote in message news:b588j0$1gpb$1 digitaldaemon.com...Some of math functions, and sqrt among them, are #define'd in math.h. Defines serve to promote sqrt/sin/cos an other calls to intrinsic calls. Mar 18 2003
|