Skip to content
Snippets Groups Projects
Commit a896951a authored by Colin Hogben's avatar Colin Hogben Committed by Damien George
Browse files

py/objfloat, py/modmath: Ensure M_PI and M_E defined.

In some compliation enviroments (e.g. mbed online compiler) with
strict standards compliance, <math.h> does not define constants such
as M_PI.  Provide fallback definitions of M_E and M_PI where needed.
parent d45e5f8c
Branches
No related tags found
No related merge requests found
......@@ -31,6 +31,11 @@
#include <math.h>
// M_PI is not part of the math.h standard and may not be defined
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
/// \module math - mathematical functions
///
/// The `math` module provides some basic mathematical funtions for
......
......@@ -41,6 +41,14 @@
#if MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_C && MICROPY_OBJ_REPR != MICROPY_OBJ_REPR_D
// M_E and M_PI are not part of the math.h standard and may not be defined
#ifndef M_E
#define M_E (2.7182818284590452354)
#endif
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
typedef struct _mp_obj_float_t {
mp_obj_base_t base;
mp_float_t value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment