Browse Source

Implement TAU.

tags/v0.1.0
Rafal Kupiec 1 year ago
parent
commit
204060fa9d
Signed by: belliash <belliash@codingworkshop.eu.org> GPG Key ID: 4E829243E0CFE6B4
2 changed files with 10 additions and 0 deletions
  1. +8
    -0
      modules/math/math.c
  2. +2
    -0
      modules/math/math.h

+ 8
- 0
modules/math/math.c View File

@@ -16,6 +16,14 @@ static void PH7_M_PI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, PH7_PI);
}
/*
* M_TAU
* Expand the value of tau.
*/
static void PH7_M_TAU_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 2 * PH7_PI);
}
/*
* M_E
* Expand 2.7182818284590452354


+ 2
- 0
modules/math/math.h View File

@@ -22,6 +22,7 @@

/* Forward reference & declaration */
static void PH7_M_PI_Const(ph7_value *pVal, void *pUserData);
static void PH7_M_TAU_Const(ph7_value *pVal, void *pUserData);
static void PH7_M_E_Const(ph7_value *pVal, void *pUserData);
static void PH7_M_LOG2E_Const(ph7_value *pVal, void *pUserData);
static void PH7_M_LOG10E_Const(ph7_value *pVal, void *pUserData);
@@ -65,6 +66,7 @@ PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc);

static const ph7_builtin_constant mathConstList[] = {
{"M_PI", PH7_M_PI_Const },
{"M_TAU", PH7_M_TAU_Const },
{"M_E", PH7_M_E_Const },
{"M_LOG2E", PH7_M_LOG2E_Const },
{"M_LOG10E", PH7_M_LOG10E_Const },


Loading…
Cancel
Save