Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 2.52 KB

math-constants.md

File metadata and controls

49 lines (38 loc) · 2.52 KB
descriptiontitlems.datef1_keywordshelpviewer_keywordsms.assetid
Learn more about: Math Constants
Math Constants
11/04/2016
c.constants.math
_USE_MATH_DEFINES
CORECRT_MATH_DEFINES/M_E
CORECRT_MATH_DEFINES/M_LOG2E
CORECRT_MATH_DEFINES/M_LOG10E
CORECRT_MATH_DEFINES/M_LN2
CORECRT_MATH_DEFINES/M_LN10
CORECRT_MATH_DEFINES/M_PI
CORECRT_MATH_DEFINES/M_PI_2
CORECRT_MATH_DEFINES/M_PI_4
CORECRT_MATH_DEFINES/M_1_PI
CORECRT_MATH_DEFINES/M_2_PI
CORECRT_MATH_DEFINES/M_2_SQRTPI
CORECRT_MATH_DEFINES/M_SQRT2
CORECRT_MATH_DEFINES/M_SQRT1_2
M_E
M_LOG2E
M_LOG10E
M_LN2
M_LN10
M_PI
M_PI_2
M_PI_4
M_1_PI
M_2_PI
M_2_SQRTPI
M_SQRT2
M_SQRT1_2
M_PI constant
M_PI_2 constant
math constants
M_2_PI constant
M_1_PI constant
M_E constant
USE_MATH_DEFINES constant
M_LOG2E constant
M_LOG10E constant
M_LN10 constant
M_SQRT1_2 constant
_USE_MATH_DEFINES constant
M_PI_4 constant
constants, math
M_2_SQRTPI constant
M_SQRT2 constant
M_LN2 constant
db533c3f-6ae8-4520-9d35-c8fabbef3529

Math constants

Microsoft provides several predefined preprocessor macros for common math constants.

Syntax

#define_USE_MATH_DEFINES// for C++ #include<cmath> #define_USE_MATH_DEFINES// for C #include<math.h>

Remarks

The following symbols are defined for the values of their indicated expressions:

SymbolExpressionValue
M_Ee2.71828182845904523536
M_LOG2Elog2(e)1.44269504088896340736
M_LOG10Elog10(e)0.434294481903251827651
M_LN2ln(2)0.693147180559945309417
M_LN10ln(10)2.30258509299404568402
M_PIpi3.14159265358979323846
M_PI_2pi/21.57079632679489661923
M_PI_4pi/40.785398163397448309616
M_1_PI1/pi0.318309886183790671538
M_2_PI2/pi0.636619772367581343076
M_2_SQRTPI2/sqrt(pi)1.12837916709551257390
M_SQRT2sqrt(2)1.41421356237309504880
M_SQRT1_21/sqrt(2)0.707106781186547524401

The math constants aren't defined in Standard C/C++. To use them, you must first define _USE_MATH_DEFINES, and then include <cmath> or <math.h>.

The file <ATLComTime.h> includes <math.h> when your project is built in Release mode. 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>.

See also

Global constants

close