diff options
author | John Langford <jl@hunch.net> | 2013-11-27 19:11:43 +0400 |
---|---|---|
committer | John Langford <jl@hunch.net> | 2013-11-27 19:11:43 +0400 |
commit | 064ff25290e2e6ca40e5a430bc285f03447ed45e (patch) | |
tree | a2e42a9e7512ff83b746bd22f5d7a5597464e389 /vowpalwabbit/parse_primitives.h | |
parent | fe8780a42c1b44d05631d1866029007a1f4f6078 (diff) |
modified parser to limit precision
Diffstat (limited to 'vowpalwabbit/parse_primitives.h')
-rw-r--r-- | vowpalwabbit/parse_primitives.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/vowpalwabbit/parse_primitives.h b/vowpalwabbit/parse_primitives.h index 90a4f9e4..4d1a6ce9 100644 --- a/vowpalwabbit/parse_primitives.h +++ b/vowpalwabbit/parse_primitives.h @@ -143,7 +143,7 @@ inline void print_substring(substring s) inline float parseFloat(char * p, char **end) { char* start = p; - + if (!*p) return 0; int s = 1; @@ -156,15 +156,18 @@ inline float parseFloat(char * p, char **end) float acc = 0; while (*p >= '0' && *p <= '9') acc = acc * 10 + *p++ - '0'; - + int num_dec = 0; if (*p == '.') { - p++; - while (*p >= '0' && *p <= '9') { - acc = acc *10 + (*p++ - '0') ; - num_dec++; + while (*(++p) >= '0' && *p <= '9') { + if (num_dec < 10) + { + acc = acc *10 + (*p - '0'); + num_dec++; + } } } + int exp_acc = 0; if(*p == 'e' || *p == 'E'){ p++; |