Fixed problem with negative exponents in floating point constants (issue #62)
git-svn-id: http://picoc.googlecode.com/svn/trunk@355 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
7560c29942
commit
172e6e5e8b
10
lex.c
10
lex.c
|
@ -174,11 +174,19 @@ enum LexToken LexGetNumber(struct LexState *Lexer, struct Value *Value)
|
||||||
|
|
||||||
if (Lexer->Pos != Lexer->End && (*Lexer->Pos == 'e' || *Lexer->Pos == 'E'))
|
if (Lexer->Pos != Lexer->End && (*Lexer->Pos == 'e' || *Lexer->Pos == 'E'))
|
||||||
{
|
{
|
||||||
|
double ExponentMultiplier = 1.0;
|
||||||
|
|
||||||
LEXER_INC(Lexer);
|
LEXER_INC(Lexer);
|
||||||
|
if (Lexer->Pos != Lexer->End && *Lexer->Pos == '-')
|
||||||
|
{
|
||||||
|
ExponentMultiplier = -1.0;
|
||||||
|
LEXER_INC(Lexer);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
FPResult *= math_pow((double)Base, (double)Result * ExponentMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value->Val->FP = FPResult;
|
Value->Val->FP = FPResult;
|
||||||
|
|
Loading…
Reference in a new issue