Skip to content

Commit a0cfbf1

Browse files
committed
Replaced the floating point macrodef constants with constexpr double in the case of C++.
Co-Authored-By: Matthijs Kooijman <matthijs@stdin.nl>
1 parent e3153b2 commit a0cfbf1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cores/arduino/Arduino.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,27 @@
3737

3838
#include "binary.h"
3939

40+
#if defined(__cplusplus)
41+
constexpr double PI = 3.1415926535897932384626433832795,
42+
HALF_PI = 1.5707963267948966192313216916398,
43+
TWO_PI = 6.283185307179586476925286766559,
44+
DEG_TO_RAD = 0.017453292519943295769236907684886,
45+
RAD_TO_DEG = 57.295779513082320876798154814105,
46+
EULER = 2.718281828459045235360287471352;
47+
#define PI PI
48+
#define HALF_PI HALF_PI
49+
#define TWO_PI TWO_PI
50+
#define DEG_TO_RAD DEG_TO_RAD
51+
#define RAD_TO_DEG RAD_TO_DEG
52+
#define EULER EULER
53+
#else
4054
#define PI 3.1415926535897932384626433832795
4155
#define HALF_PI 1.5707963267948966192313216916398
4256
#define TWO_PI 6.283185307179586476925286766559
4357
#define DEG_TO_RAD 0.017453292519943295769236907684886
4458
#define RAD_TO_DEG 57.295779513082320876798154814105
4559
#define EULER 2.718281828459045235360287471352
60+
#endif
4661

4762
#ifdef __cplusplus
4863
extern "C"{

0 commit comments

Comments
 (0)