diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-26 19:35:51 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-26 19:35:51 -0300 |
commit | 66fc0f554aa45616d868ab820f8174a85817978d (patch) | |
tree | bad487ae2aa4c7ac27959bf0ab9925bf0b130317 | |
parent | d6e4c29733b43130c5222c49b3c4b9dfcd8bb893 (diff) | |
download | lua-66fc0f554aa45616d868ab820f8174a85817978d.tar.gz lua-66fc0f554aa45616d868ab820f8174a85817978d.tar.bz2 lua-66fc0f554aa45616d868ab820f8174a85817978d.zip |
using double to read numbers.
-rw-r--r-- | lex.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,4 +1,4 @@ | |||
1 | char *rcs_lex = "$Id: lex.c,v 2.27 1996/02/14 13:35:51 roberto Exp roberto $"; | 1 | char *rcs_lex = "$Id: lex.c,v 2.28 1996/02/14 19:11:09 roberto Exp roberto $"; |
2 | 2 | ||
3 | 3 | ||
4 | #include <ctype.h> | 4 | #include <ctype.h> |
@@ -135,7 +135,7 @@ static int read_long_string (void) | |||
135 | 135 | ||
136 | int luaY_lex (void) | 136 | int luaY_lex (void) |
137 | { | 137 | { |
138 | float a; | 138 | double a; |
139 | static int linelasttoken = 0; | 139 | static int linelasttoken = 0; |
140 | if (lua_debug) | 140 | if (lua_debug) |
141 | luaI_codedebugline(linelasttoken); | 141 | luaI_codedebugline(linelasttoken); |
@@ -297,22 +297,22 @@ int luaY_lex (void) | |||
297 | case '0': case '1': case '2': case '3': case '4': | 297 | case '0': case '1': case '2': case '3': case '4': |
298 | case '5': case '6': case '7': case '8': case '9': | 298 | case '5': case '6': case '7': case '8': case '9': |
299 | a=0.0; | 299 | a=0.0; |
300 | do { a=10*a+current-'0'; save_and_next(); } while (isdigit(current)); | 300 | do { a=10.0*a+(current-'0'); save_and_next(); } while (isdigit(current)); |
301 | if (current == '.') save_and_next(); | 301 | if (current == '.') save_and_next(); |
302 | fraction: | 302 | fraction: |
303 | { float da=0.1; | 303 | { double da=0.1; |
304 | while (isdigit(current)) | 304 | while (isdigit(current)) |
305 | {a+=(current-'0')*da; da/=10.0; save_and_next()}; | 305 | {a+=(current-'0')*da; da/=10.0; save_and_next()}; |
306 | if (current == 'e' || current == 'E') | 306 | if (current == 'e' || current == 'E') |
307 | { | 307 | { |
308 | int e=0; | 308 | int e=0; |
309 | int neg; | 309 | int neg; |
310 | float ea; | 310 | double ea; |
311 | save_and_next(); | 311 | save_and_next(); |
312 | neg=(current=='-'); | 312 | neg=(current=='-'); |
313 | if (current == '+' || current == '-') save_and_next(); | 313 | if (current == '+' || current == '-') save_and_next(); |
314 | if (!isdigit(current)) return WRONGTOKEN; | 314 | if (!isdigit(current)) return WRONGTOKEN; |
315 | do { e=10*e+current-'0'; save_and_next(); } while (isdigit(current)); | 315 | do { e=10.0*e+(current-'0'); save_and_next(); } while (isdigit(current)); |
316 | for (ea=neg?0.1:10.0; e>0; e>>=1) | 316 | for (ea=neg?0.1:10.0; e>0; e>>=1) |
317 | { | 317 | { |
318 | if (e & 1) a*=ea; | 318 | if (e & 1) a*=ea; |