Well, the problem isn't what you're passing to it, but what it returns.
Well, the problem isn't what you're passing to it, but what it returns.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I see that based on sqrt - C++ Reference
It only returns float or double types.
Code:#include <iostream> #include <string> #include <math.h> using namespace std; template<class T> T inner_product(const T &a, const T &b){ return a * a + b * b; } template<class T> T squareroot(const T &c){ return sqrt(c); } template<class T> T pythagorean(const T &a, const T &b){ return static_cast<T>(squareroot(inner_product(a, b))); } int main(){ int a = 2, b = 4; double c = 10, d = 3; string string1 = "This is a test."; string string2 = "This is another test with more characters."; cout << pythagorean(a, b) << endl << pythagorean(c, d) << endl << pythagorean(string1.size(), string2.size()); return 0; }
Should I be using Code::Blocks if it didn't report that warning?
IDE + Complier: Code::Blocks w/ GCC
PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
OSes: CentOS 6.2 x64 & Win 7 Ultimate x64
Code::Blocks is just an IDE. What version of GCC are you running?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I'm not sure how to tell ... it is the default GNU GCC compiler Code::Blocks uses.
IDE + Complier: Code::Blocks w/ GCC
PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
OSes: CentOS 6.2 x64 & Win 7 Ultimate x64
>> I'm not sure how to tell ... it is the default GNU GCC compiler Code::Blocks uses.
You IDE users are hilarious. Open up a command prompt and type:
g++ --version [ENTER]
If you don't get a response you'll need to navigate to the Code::Blocks bin directory (unless you have GCC installed somewhere else, of course, in which case you can just search your drive for g++.exe).
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
g++ (GCC) 2.4.5 (mingw-vista special)
IDE + Complier: Code::Blocks w/ GCC
PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
OSes: CentOS 6.2 x64 & Win 7 Ultimate x64
>> g++ (GCC) 2.4.5 (mingw-vista special)
Oh man, you are seriously out of date. That was released back in '93!
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
My linux server reports it correctly though, but doesn't seem to like quotes ...
Code:root@server [~]# g++ -o pythag pythag.cpp pythag.cpp: In function âT squareroot(const T&) [with T = int]â: pythag.cpp:16: instantiated from âT pythagorean(const T&, const T&) [with T = int]â pythag.cpp:26: instantiated from here pythag.cpp:12: warning: converting to âintâ from âdoubleâ pythag.cpp: In function âT squareroot(const T&) [with T = long unsigned int]â: pythag.cpp:16: instantiated from âT pythagorean(const T&, const T&) [with T = size_t]â pythag.cpp:28: instantiated from here pythag.cpp:12: warning: converting to âlong unsigned intâ from âdoubleâ root@server [~]# g++ --version g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
IDE + Complier: Code::Blocks w/ GCC
PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
OSes: CentOS 6.2 x64 & Win 7 Ultimate x64
Here is the latest version of the mingw compiler. Just be sure to either make a copy of the existing GCC directory or install it in a new one.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I think I am going to use a different IDE ... changing any options in Code::Blocks eats up 50% of all 4 of my processor cores and takes 5 seconds to open. Also, after I changed the compiler I can no longer get the project to run ... it builds and shows the errors though.
IDE + Complier: Code::Blocks w/ GCC
PC: AMD Phenom x4 2.2Ghz w/ 8G RAM
OSes: CentOS 6.2 x64 & Win 7 Ultimate x64
>> Thanks, I'll give that a shot before I abandon Code::Blocks.
You don't have to use another IDE!
Just unzip the mingw file into a directory and then go to your IDE's compiler options and set it up to use the new compiler (I've never used that IDE so I don't know what the exact process is, though). Alternately, just make a copy of the old GCC directory as a backup, and then replace it with the new one, but keep the directory name and structure the same. That way, you don't even have to "tell" Code::Blocks - it will just assume that it's using the same compiler.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
>> I think I am going to use a different IDE ... changing any options in Code::Blocks eats up 50% of all 4 of my processor cores and takes 5 seconds to open. Also, after I changed the compiler I can no longer get the project to run ... it builds and shows the errors though.
Oh, ok I missed that post. Well, I don't use an IDE and I really can't think of one off the top of my head. Dev-C++ *was* supposedly pretty decent, but I think the project's been since abandoned. Oh well, I'm sure someone here will have a good suggestion for you.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }