Removed superseded math library references.
git-svn-id: http://picoc.googlecode.com/svn/trunk@541 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
e6f78cff7e
commit
4919d40cd2
50
clibrary.c
50
clibrary.c
|
@ -198,17 +198,17 @@ void PrintFP(double Num, struct OutputStream *Stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Num >= 1e7)
|
if (Num >= 1e7)
|
||||||
Exponent = math_log10(Num);
|
Exponent = log10(Num);
|
||||||
else if (Num <= 1e-7 && Num != 0.0)
|
else if (Num <= 1e-7 && Num != 0.0)
|
||||||
Exponent = math_log10(Num) - 0.999999999;
|
Exponent = log10(Num) - 0.999999999;
|
||||||
|
|
||||||
Num /= math_pow(10.0, Exponent);
|
Num /= pow(10.0, Exponent);
|
||||||
PrintInt((long)Num, 0, FALSE, FALSE, Stream);
|
PrintInt((long)Num, 0, FALSE, FALSE, Stream);
|
||||||
PrintCh('.', Stream);
|
PrintCh('.', Stream);
|
||||||
Num = (Num - (long)Num) * 10;
|
Num = (Num - (long)Num) * 10;
|
||||||
if (math_abs(Num) >= 1e-7)
|
if (abs(Num) >= 1e-7)
|
||||||
{
|
{
|
||||||
for (MaxDecimal = 6; MaxDecimal > 0 && math_abs(Num) >= 1e-7; Num = (Num - (long)(Num + 1e-7)) * 10, MaxDecimal--)
|
for (MaxDecimal = 6; MaxDecimal > 0 && abs(Num) >= 1e-7; Num = (Num - (long)(Num + 1e-7)) * 10, MaxDecimal--)
|
||||||
PrintCh('0' + (long)(Num + 1e-7), Stream);
|
PrintCh('0' + (long)(Num + 1e-7), Stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -367,95 +367,95 @@ void LibExit(struct ParseState *Parser, struct Value *ReturnValue, struct Value
|
||||||
PlatformExit(Param[0]->Val->Integer);
|
PlatformExit(Param[0]->Val->Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PICOC_MATH_LIBRARY
|
#ifdef PICOC_LIBRARY
|
||||||
void LibSin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibSin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_sin(Param[0]->Val->FP);
|
ReturnValue->Val->FP = sin(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibCos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibCos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_cos(Param[0]->Val->FP);
|
ReturnValue->Val->FP = cos(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibTan(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibTan(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_tan(Param[0]->Val->FP);
|
ReturnValue->Val->FP = tan(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibAsin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibAsin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_asin(Param[0]->Val->FP);
|
ReturnValue->Val->FP = asin(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibAcos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibAcos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_acos(Param[0]->Val->FP);
|
ReturnValue->Val->FP = acos(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibAtan(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibAtan(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_atan(Param[0]->Val->FP);
|
ReturnValue->Val->FP = atan(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibSinh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibSinh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_sinh(Param[0]->Val->FP);
|
ReturnValue->Val->FP = sinh(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibCosh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibCosh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_cosh(Param[0]->Val->FP);
|
ReturnValue->Val->FP = cosh(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibTanh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibTanh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_tanh(Param[0]->Val->FP);
|
ReturnValue->Val->FP = tanh(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibExp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibExp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_exp(Param[0]->Val->FP);
|
ReturnValue->Val->FP = exp(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibFabs(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibFabs(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_fabs(Param[0]->Val->FP);
|
ReturnValue->Val->FP = fabs(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibLog(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibLog(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_log(Param[0]->Val->FP);
|
ReturnValue->Val->FP = log(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibLog10(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibLog10(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_log10(Param[0]->Val->FP);
|
ReturnValue->Val->FP = log10(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibPow(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibPow(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_pow(Param[0]->Val->FP, Param[1]->Val->FP);
|
ReturnValue->Val->FP = pow(Param[0]->Val->FP, Param[1]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibSqrt(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibSqrt(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_sqrt(Param[0]->Val->FP);
|
ReturnValue->Val->FP = sqrt(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibRound(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibRound(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_floor(Param[0]->Val->FP + 0.5); /* XXX - fix for soft float */
|
ReturnValue->Val->FP = floor(Param[0]->Val->FP + 0.5); /* XXX - fix for soft float */
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibCeil(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibCeil(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_ceil(Param[0]->Val->FP);
|
ReturnValue->Val->FP = ceil(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibFloor(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
void LibFloor(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||||
{
|
{
|
||||||
ReturnValue->Val->FP = math_floor(Param[0]->Val->FP);
|
ReturnValue->Val->FP = floor(Param[0]->Val->FP);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ struct LibraryFunction CLibrary[] =
|
||||||
{ LibGets, "char *gets(char *);" },
|
{ LibGets, "char *gets(char *);" },
|
||||||
{ LibGetc, "int getchar();" },
|
{ LibGetc, "int getchar();" },
|
||||||
{ LibExit, "void exit(int);" },
|
{ LibExit, "void exit(int);" },
|
||||||
#ifdef PICOC_MATH_LIBRARY
|
#ifdef PICOC_LIBRARY
|
||||||
{ LibSin, "float sin(float);" },
|
{ LibSin, "float sin(float);" },
|
||||||
{ LibCos, "float cos(float);" },
|
{ LibCos, "float cos(float);" },
|
||||||
{ LibTan, "float tan(float);" },
|
{ LibTan, "float tan(float);" },
|
||||||
|
|
2
lex.c
2
lex.c
|
@ -198,7 +198,7 @@ enum LexToken LexGetNumber(struct LexState *Lexer, struct Value *Value)
|
||||||
for (Result = 0; Lexer->Pos != Lexer->End && IS_BASE_DIGIT(*Lexer->Pos, Base); LEXER_INC(Lexer))
|
for (Result = 0; Lexer->Pos != Lexer->End && IS_BASE_DIGIT(*Lexer->Pos, Base); LEXER_INC(Lexer))
|
||||||
Result = Result * (double)Base + GET_BASE_DIGIT(*Lexer->Pos);
|
Result = Result * (double)Base + GET_BASE_DIGIT(*Lexer->Pos);
|
||||||
|
|
||||||
FPResult *= math_pow((double)Base, (double)Result * ExponentMultiplier);
|
FPResult *= pow((double)Base, (double)Result * ExponentMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value->Val->FP = FPResult;
|
Value->Val->FP = FPResult;
|
||||||
|
|
45
platform.h
45
platform.h
|
@ -134,49 +134,4 @@ extern int ExitBuf[];
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define math_abs(x) (((x) < 0) ? (-(x)) : (x))
|
|
||||||
#ifdef NEED_MATH_LIBRARY
|
|
||||||
extern double math_sin(double x);
|
|
||||||
extern double math_cos(double x);
|
|
||||||
extern double math_tan(double x);
|
|
||||||
extern double math_asin(double x);
|
|
||||||
extern double math_acos(double x);
|
|
||||||
extern double math_atan(double x);
|
|
||||||
extern double math_sinh(double x);
|
|
||||||
extern double math_cosh(double x);
|
|
||||||
extern double math_tanh(double x);
|
|
||||||
extern double math_asinh(double x);
|
|
||||||
extern double math_acosh(double x);
|
|
||||||
extern double math_atanh(double x);
|
|
||||||
extern double math_exp(double x);
|
|
||||||
extern double math_fabs(double x);
|
|
||||||
extern double math_log(double x);
|
|
||||||
extern double math_log10(double x);
|
|
||||||
extern double math_pow(double x, double y);
|
|
||||||
extern double math_sqrt(double x);
|
|
||||||
extern double math_floor(double x);
|
|
||||||
extern double math_ceil(double x);
|
|
||||||
#else /* NEED_MATH_LIBRARY */
|
|
||||||
#define math_sin(x) sin(x)
|
|
||||||
#define math_cos(x) cos(x)
|
|
||||||
#define math_tan(x) tan(x)
|
|
||||||
#define math_asin(x) asin(x)
|
|
||||||
#define math_acos(x) acos(x)
|
|
||||||
#define math_atan(x) atan(x)
|
|
||||||
#define math_sinh(x) sinh(x)
|
|
||||||
#define math_cosh(x) cosh(x)
|
|
||||||
#define math_tanh(x) tanh(x)
|
|
||||||
#define math_asinh(x) asinh(x)
|
|
||||||
#define math_acosh(x) acosh(x)
|
|
||||||
#define math_atanh(x) atanh(x)
|
|
||||||
#define math_exp(x) exp(x)
|
|
||||||
#define math_fabs(x) fabs(x)
|
|
||||||
#define math_log(x) log(x)
|
|
||||||
#define math_log10(x) log10(x)
|
|
||||||
#define math_pow(x,y) pow(x,y)
|
|
||||||
#define math_sqrt(x) sqrt(x)
|
|
||||||
#define math_floor(x) floor(x)
|
|
||||||
#define math_ceil(x) ceil(x)
|
|
||||||
#endif /* NEED_MATH_LIBRARY */
|
|
||||||
|
|
||||||
#endif /* PLATFORM_H */
|
#endif /* PLATFORM_H */
|
||||||
|
|
Loading…
Reference in a new issue