Costanti MathMath Constants

SintassiSyntax

#define _USE_MATH_DEFINES // for C++  
#include <cmath>  

#define _USE_MATH_DEFINES // for C  
#include <math.h>  

NoteRemarks

I simboli seguenti sono definiti per i valori delle espressioni indicate:The following symbols are defined for the values of their indicated expressions:

SimboloSymbol EspressioneExpression ValoreValue
M_EM_E ee 2.718281828459045235362.71828182845904523536
M_LOG2EM_LOG2E log2(e)log2(e) 1.442695040888963407361.44269504088896340736
M_LOG10EM_LOG10E log10(e)log10(e) 0.4342944819032518276510.434294481903251827651
M_LN2M_LN2 ln(2)ln(2) 0.6931471805599453094170.693147180559945309417
M_LN10M_LN10 ln(10)ln(10) 2.302585092994045684022.30258509299404568402
M_PIM_PI pipi 3.141592653589793238463.14159265358979323846
M_PI_2M_PI_2 pi/2pi/2 1.570796326794896619231.57079632679489661923
M_PI_4M_PI_4 pi/4pi/4 0.7853981633974483096160.785398163397448309616
M_1_PIM_1_PI 1/pi1/pi 0.3183098861837906715380.318309886183790671538
M_2_PIM_2_PI 2/pi2/pi 0.6366197723675813430760.636619772367581343076
M_2_SQRTPIM_2_SQRTPI 2/sqrt(pi)2/sqrt(pi) 1.128379167095512573901.12837916709551257390
M_SQRT2M_SQRT2 sqrt(2)sqrt(2) 1.414213562373095048801.41421356237309504880
M_SQRT1_2M_SQRT1_2 1/sqrt(2)1/sqrt(2) 0.7071067811865475244010.707106781186547524401

Le costanti Math non sono definite in C/C++ standard.Math Constants are not defined in Standard C/C++. Per usarle, è prima necessario definire _USE_MATH_DEFINES e quindi includere cmath o math.h.To use them, you must first define _USE_MATH_DEFINES and then include cmath or math.h.

Se il progetto viene compilato in modalità di rilascio, il file ATLComTime.h include math.h.The file ATLComTime.h includes math.h when your project is built in Release mode. Se si usa almeno una delle costanti Math in un progetto che include anche ATLComTime.h, è necessario definire _USE_MATH_DEFINES prima di includere ATLComTime.h.If you use one or more of the math constants in a project that also includes ATLComTime.h, you must define _USE_MATH_DEFINES before you include ATLComTime.h.

Vedere ancheSee Also

Costanti globaliGlobal Constants