visual studio 2010 - #include -


What's wrong with the code snippet below that VS2010 will not compile it?

  int m = sqrt (n);   

(I am trying to ensure that there is a prime prime ...)

You have to pass a specific floating point type on sqrt - there is no integer overload. Use eg:

  long double mi = sqrt (static_cast & lt; long double & gt; (n));   

As you include cmath not math.h , I'm assuming that you want C ++ For C, you will need to use eg:

  double M = sqrt ((double) n);   

You just error means that the compiler can not automatically select a sqrt function for you - you converted the integer passed to a floating point type And the compiler does not know which floating point type and the sqrt function should be selected.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -