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:
zik.saleeba 2009-10-29 19:26:47 +00:00
parent 7560c29942
commit 172e6e5e8b

10
lex.c
View file

@ -174,11 +174,19 @@ enum LexToken LexGetNumber(struct LexState *Lexer, struct Value *Value)
if (Lexer->Pos != Lexer->End && (*Lexer->Pos == 'e' || *Lexer->Pos == 'E'))
{
double ExponentMultiplier = 1.0;
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))
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;