"more than one instance of the overloaded function" std :: pow "matches the argument list"

With C ++, I'm trying

#define TINY std::pow(10,-10)

I provide code with information about #includeand namespace for the class (.h) where TINY is defined

#pragma once
#include "MMath.h"
#include <string>
#include <cmath>
#include <vector>

using namespace std;

#define TINY std::pow(10,-10)

I use TINY in some function implementation in a .cpp file, and TINY gives an error

IntelliSense: more than one instance of the overloaded function "std :: pow" matches an argument list

What is the correct syntax?

+5
source share
3 answers

: , std:: pow() - 1.0E-10; , , - .

#define. std::pow() , (int, int) . , . , , :

      float pow (       float base,       float exponent );
     double pow (      double base,         int exponent );
long double pow ( long double base,         int exponent );

:

std::pow(10.0f, -10.0f)
std::pow(10.0, -10)
std::pow(10.0L, -10)

.

+10

, - pow, ,

const double TINY = 1E-10; //1e-10 is 10 to the power of -10
+2

std::pow(10.0,-10.0): std::pow , ; 10.0,-10.0 :

double pow(double base, double exponent);

Please note that this #definemay be suboptimal depending on usage TINY: every time you use it in your code, a call will be made std::powto calculate the same value. A better approach would be to use a static variable, set it once, and use it from this point.

+1
source

All Articles