Fixed LUA_NUMBER_INTEGRAL definition in user_config.h.

This commit is contained in:
HuangRui 2015-01-26 19:57:54 +08:00
parent e11721ebfd
commit 646eaec29c
2 changed files with 154 additions and 120 deletions

View File

@ -7,7 +7,7 @@
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 0.9.5"
#define BUILD_DATE "build 20150124"
#define BUILD_DATE "build 20150126"
// #define FLASH_512K
// #define FLASH_1M
@ -67,8 +67,10 @@
#define LUA_USE_MODULES_MQTT
#endif /* LUA_USE_MODULES */
// #define LUA_NUMBER_INTEGRAL
#define LUA_NUMBER_INTEGRAL
#ifndef LUA_NUMBER_INTEGRAL
#define PRINTF_LONG_SUPPORT
#endif
#define LUA_OPTRAM
#ifdef LUA_OPTRAM

View File

@ -1,15 +1,18 @@
#include "c_math.h"
#include "c_types.h"
double floor(double x){
double floor(double x)
{
return (double) (x < 0.f ? (((int) x) - 1) : ((int) x));
}
double pow(double x, double y){
double pow(double x, double y)
{
#define MAXEXP 2031 /* (MAX_EXP * 16) - 1 */
#define MINEXP -2047 /* (MIN_EXP * 16) - 1 */
#define HUGE MAXFLOAT
double a1[] = {
double a1[] =
{
1.0,
0.95760328069857365,
0.91700404320467123,
@ -27,8 +30,9 @@ double a1[] = {
0.54525386633262883,
0.52213689121370692,
0.50000000000000000
};
double a2[] = {
};
double a2[] =
{
0.24114209503420288E-17,
0.92291566937243079E-18,
-0.15241915231122319E-17,
@ -37,33 +41,36 @@ double a2[] = {
-0.44654376565694490E-17,
0.29306999570789681E-17,
0.11260851040933474E-17
};
double p1 = 0.833333333333332114e-1;
double p2 = 0.125000000005037992e-1;
double p3 = 0.223214212859242590e-2;
double p4 = 0.434457756721631196e-3;
double q1 = 0.693147180559945296e0;
double q2 = 0.240226506959095371e0;
double q3 = 0.555041086640855953e-1;
double q4 = 0.961812905951724170e-2;
double q5 = 0.133335413135857847e-2;
double q6 = 0.154002904409897646e-3;
double q7 = 0.149288526805956082e-4;
double k = 0.442695040888963407;
};
double p1 = 0.833333333333332114e-1;
double p2 = 0.125000000005037992e-1;
double p3 = 0.223214212859242590e-2;
double p4 = 0.434457756721631196e-3;
double q1 = 0.693147180559945296e0;
double q2 = 0.240226506959095371e0;
double q3 = 0.555041086640855953e-1;
double q4 = 0.961812905951724170e-2;
double q5 = 0.133335413135857847e-2;
double q6 = 0.154002904409897646e-3;
double q7 = 0.149288526805956082e-4;
double k = 0.442695040888963407;
double frexp(), g, ldexp(), r, u1, u2, v, w, w1, w2, y1, y2, z;
int iw1, m, p;
if (y == 0.0)
return(1.0);
if (x <= 0.0) {
if (x == 0.0) {
return (1.0);
if (x <= 0.0)
{
if (x == 0.0)
{
if (y > 0.0)
return(x);
return (x);
//cmemsg(FP_POWO, &y);
//return(HUGE);
}
else {
else
{
//cmemsg(FP_POWN, &x);
x = -x;
}
@ -95,57 +102,70 @@ double k = 0.442695040888963407;
w = 0.0625 * (double)((int)(16.0 * w2));
iw1 = 16.0 * (w1 + w);
w2 -= w;
while (w2 > 0.0) {
while (w2 > 0.0)
{
iw1++;
w2 -= 0.0625;
}
if (iw1 > MAXEXP) {
if (iw1 > MAXEXP)
{
//cmemsg(FP_POWO, &y);
return(HUGE);
return (HUGE);
}
if (iw1 < MINEXP) {
if (iw1 < MINEXP)
{
//cmemsg(FP_POWU, &y);
return(0.0);
return (0.0);
}
m = iw1 / 16;
if (iw1 >= 0)
m++;
p = 16 * m - iw1;
z = ((((((q7*w2 + q6)*w2 + q5)*w2 + q4)*w2 + q3)*w2 + q2)*w2 + q1)*w2;
z = ((((((q7 * w2 + q6) * w2 + q5) * w2 + q4) * w2 + q3) * w2 + q2) * w2 + q1) * w2;
z = a1[p] + a1[p] * z;
return(ldexp(z, m));
return (ldexp(z, m));
}
#if 0
#ifndef __math_68881
double atan(double x){
double atan(double x)
{
return x;
}
double cos(double x){
double cos(double x)
{
return x;
}
double sin(double x){
double sin(double x)
{
return x;
}
double tan(double x){
double tan(double x)
{
return x;
}
double tanh(double x){
double tanh(double x)
{
return x;
}
double frexp(double x, int *y){
double frexp(double x, int *y)
{
return x;
}
double modf(double x, double *y){
double modf(double x, double *y)
{
return x;
}
double ceil(double x){
double ceil(double x)
{
return x;
}
double fabs(double x){
double fabs(double x)
{
return x;
}
double floor(double x){
double floor(double x)
{
return x;
}
#endif /* ! defined (__math_68881) */
@ -154,40 +174,52 @@ double floor(double x){
#ifndef _REENT_ONLY
#ifndef __math_68881
double acos(double x){
double acos(double x)
{
return x;
}
double asin(double x){
double asin(double x)
{
return x;
}
double atan2(double x, double y){
double atan2(double x, double y)
{
return x;
}
double cosh(double x){
double cosh(double x)
{
return x;
}
double sinh(double x){
double sinh(double x)
{
return x;
}
double exp(double x){
double exp(double x)
{
return x;
}
double ldexp(double x, int y){
double ldexp(double x, int y)
{
return x;
}
double log(double x){
double log(double x)
{
return x;
}
double log10(double x){
double log10(double x)
{
return x;
}
double pow(double x, double y){
double pow(double x, double y)
{
return x;
}
double sqrt(double x){
double sqrt(double x)
{
return x;
}
double fmod(double x, double y){
double fmod(double x, double y)
{
return x;
}
#endif /* ! defined (__math_68881) */